|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NuGet.Versioning;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
@ -24,19 +25,47 @@ namespace Volo.Abp.Cli.ProjectModification
|
|
|
|
|
Logger = NullLogger<VoloNugetPackagesVersionUpdater>.Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool switchToStable = false)
|
|
|
|
|
public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool switchToStable = false, bool checkAll = false)
|
|
|
|
|
{
|
|
|
|
|
var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);
|
|
|
|
|
|
|
|
|
|
foreach (var filePath in projectPaths)
|
|
|
|
|
if (checkAll)
|
|
|
|
|
{
|
|
|
|
|
await UpdateInternalAsync(filePath, includePreviews, switchToStable);
|
|
|
|
|
Task.WaitAll(projectPaths.Select(projectPath => UpdateInternalAsync(projectPath, includePreviews, switchToStable)).ToArray());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var latestVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core");
|
|
|
|
|
var latestVersionFromMyGet = await GetLatestVersionFromMyGet("Volo.Abp.Core");
|
|
|
|
|
|
|
|
|
|
async Task UpdateAsync(string filePath)
|
|
|
|
|
{
|
|
|
|
|
var fileContent = File.ReadAllText(filePath);
|
|
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, includePreviews, switchToStable, latestVersionFromNuget, latestVersionFromMyGet);
|
|
|
|
|
|
|
|
|
|
File.WriteAllText(filePath, updatedContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task.WaitAll(projectPaths.Select(UpdateAsync).ToArray());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateProjectAsync(string projectPath, bool includePreviews = false, bool switchToStable = false)
|
|
|
|
|
public async Task UpdateProjectAsync(string projectPath, bool includePreviews = false, bool switchToStable = false, bool checkAll = false)
|
|
|
|
|
{
|
|
|
|
|
await UpdateInternalAsync(projectPath, includePreviews, switchToStable);
|
|
|
|
|
if (checkAll)
|
|
|
|
|
{
|
|
|
|
|
await UpdateInternalAsync(projectPath, includePreviews, switchToStable);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var latestVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core");
|
|
|
|
|
var latestVersionFromMyGet = await GetLatestVersionFromMyGet("Volo.Abp.Core");
|
|
|
|
|
|
|
|
|
|
var fileContent = File.ReadAllText(projectPath);
|
|
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, includePreviews, switchToStable, latestVersionFromNuget, latestVersionFromMyGet);
|
|
|
|
|
|
|
|
|
|
File.WriteAllText(projectPath, updatedContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual async Task UpdateInternalAsync(string projectPath, bool includePreviews = false, bool switchToStable = false)
|
|
|
|
|
@ -47,7 +76,7 @@ namespace Volo.Abp.Cli.ProjectModification
|
|
|
|
|
File.WriteAllText(projectPath, updatedContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<string> UpdateVoloPackagesAsync(string content, bool includePreviews = false, bool switchToStable = false)
|
|
|
|
|
private async Task<string> UpdateVoloPackagesAsync(string content, bool includePreviews = false, bool switchToStable = false, SemanticVersion latestNugetVersion = null, string latestMyGetVersion = null)
|
|
|
|
|
{
|
|
|
|
|
string packageId = null;
|
|
|
|
|
|
|
|
|
|
@ -81,7 +110,7 @@ namespace Volo.Abp.Cli.ProjectModification
|
|
|
|
|
|
|
|
|
|
if (includePreviews || (currentVersion.Contains("-preview") && !switchToStable))
|
|
|
|
|
{
|
|
|
|
|
var latestVersion = await GetLatestVersionFromMyGet(packageId);
|
|
|
|
|
var latestVersion = latestMyGetVersion ?? await GetLatestVersionFromMyGet(packageId);
|
|
|
|
|
|
|
|
|
|
if (currentVersion != latestVersion)
|
|
|
|
|
{
|
|
|
|
|
@ -95,7 +124,7 @@ namespace Volo.Abp.Cli.ProjectModification
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var latestVersion = await _nuGetService.GetLatestVersionOrNullAsync(packageId);
|
|
|
|
|
var latestVersion = latestNugetVersion ?? await _nuGetService.GetLatestVersionOrNullAsync(packageId);
|
|
|
|
|
|
|
|
|
|
if (latestVersion != null && (currentVersion.Contains("-preview") || currentSemanticVersion < latestVersion))
|
|
|
|
|
{
|
|
|
|
|
@ -109,7 +138,7 @@ namespace Volo.Abp.Cli.ProjectModification
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(doc.OuterXml);
|
|
|
|
|
return doc.OuterXml;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|