|
|
|
@ -25,23 +25,30 @@ namespace Volo.Abp.Cli.ProjectModification |
|
|
|
Logger = NullLogger<VoloNugetPackagesVersionUpdater>.Instance; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool switchToStable = false, bool checkAll = false) |
|
|
|
public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false, bool checkAll = false) |
|
|
|
{ |
|
|
|
var projectPaths = ProjectFinder.GetProjectFiles(solutionPath); |
|
|
|
|
|
|
|
if (checkAll) |
|
|
|
{ |
|
|
|
Task.WaitAll(projectPaths.Select(projectPath => UpdateInternalAsync(projectPath, includePreviews, switchToStable)).ToArray()); |
|
|
|
Task.WaitAll(projectPaths.Select(projectPath => UpdateInternalAsync(projectPath, includePreviews, includeReleaseCandidates, switchToStable)).ToArray()); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var latestVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core"); |
|
|
|
var latestVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates : includeReleaseCandidates); |
|
|
|
var latestReleaseCandidateVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates : true); |
|
|
|
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); |
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, |
|
|
|
includePreviews, |
|
|
|
includeReleaseCandidates, |
|
|
|
switchToStable, |
|
|
|
latestVersionFromNuget, |
|
|
|
latestReleaseCandidateVersionFromNuget, |
|
|
|
latestVersionFromMyGet); |
|
|
|
|
|
|
|
File.WriteAllText(filePath, updatedContent); |
|
|
|
} |
|
|
|
@ -50,33 +57,47 @@ namespace Volo.Abp.Cli.ProjectModification |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async Task UpdateProjectAsync(string projectPath, bool includePreviews = false, bool switchToStable = false, bool checkAll = false) |
|
|
|
public async Task UpdateProjectAsync(string projectPath, bool includeNightlyPreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false, bool checkAll = false) |
|
|
|
{ |
|
|
|
if (checkAll) |
|
|
|
{ |
|
|
|
await UpdateInternalAsync(projectPath, includePreviews, switchToStable); |
|
|
|
await UpdateInternalAsync(projectPath, includeNightlyPreviews, includeReleaseCandidates, switchToStable); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var latestVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core"); |
|
|
|
var latestReleaseCandidateVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates : true); |
|
|
|
var latestVersionFromMyGet = await GetLatestVersionFromMyGet("Volo.Abp.Core"); |
|
|
|
|
|
|
|
var fileContent = File.ReadAllText(projectPath); |
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, includePreviews, switchToStable, latestVersionFromNuget, latestVersionFromMyGet); |
|
|
|
|
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, |
|
|
|
includeNightlyPreviews, |
|
|
|
includeReleaseCandidates, |
|
|
|
switchToStable, |
|
|
|
latestVersionFromNuget, |
|
|
|
latestReleaseCandidateVersionFromNuget, |
|
|
|
latestVersionFromMyGet); |
|
|
|
|
|
|
|
File.WriteAllText(projectPath, updatedContent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task UpdateInternalAsync(string projectPath, bool includePreviews = false, bool switchToStable = false) |
|
|
|
protected virtual async Task UpdateInternalAsync(string projectPath, bool includeNightlyPreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false) |
|
|
|
{ |
|
|
|
var fileContent = File.ReadAllText(projectPath); |
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, includePreviews, switchToStable); |
|
|
|
var updatedContent = await UpdateVoloPackagesAsync(fileContent, includeNightlyPreviews, includeReleaseCandidates, switchToStable); |
|
|
|
|
|
|
|
File.WriteAllText(projectPath, updatedContent); |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<string> UpdateVoloPackagesAsync(string content, bool includePreviews = false, bool switchToStable = false, SemanticVersion latestNugetVersion = null, string latestMyGetVersion = null) |
|
|
|
private async Task<string> UpdateVoloPackagesAsync(string content, |
|
|
|
bool includeNightlyPreviews = false, |
|
|
|
bool includeReleaseCandidates = false, |
|
|
|
bool switchToStable = false, |
|
|
|
SemanticVersion latestNugetVersion = null, |
|
|
|
SemanticVersion latestNugetReleaseCandidateVersion = null, |
|
|
|
string latestMyGetVersion = null) |
|
|
|
{ |
|
|
|
string packageId = null; |
|
|
|
|
|
|
|
@ -108,7 +129,7 @@ namespace Volo.Abp.Cli.ProjectModification |
|
|
|
|
|
|
|
Logger.LogDebug("Checking package: \"{0}\" - Current version: {1}", packageId, currentSemanticVersion); |
|
|
|
|
|
|
|
if (includePreviews || (currentVersion.Contains("-preview") && !switchToStable)) |
|
|
|
if ((includeNightlyPreviews || (currentVersion.Contains("-preview") && !switchToStable)) && !includeReleaseCandidates) |
|
|
|
{ |
|
|
|
var latestVersion = latestMyGetVersion ?? await GetLatestVersionFromMyGet(packageId); |
|
|
|
|
|
|
|
@ -124,9 +145,17 @@ namespace Volo.Abp.Cli.ProjectModification |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var latestVersion = latestNugetVersion ?? await _nuGetService.GetLatestVersionOrNullAsync(packageId); |
|
|
|
SemanticVersion latestVersion; |
|
|
|
if (currentSemanticVersion.IsPrerelease && !switchToStable) |
|
|
|
{ |
|
|
|
latestVersion = latestNugetReleaseCandidateVersion ?? await _nuGetService.GetLatestVersionOrNullAsync(packageId, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
latestVersion = latestNugetVersion ?? await _nuGetService.GetLatestVersionOrNullAsync(packageId, includeReleaseCandidates: includeReleaseCandidates); |
|
|
|
} |
|
|
|
|
|
|
|
if (latestVersion != null && (currentVersion.Contains("-preview") || currentSemanticVersion < latestVersion)) |
|
|
|
if (latestVersion != null && (currentSemanticVersion.IsPrerelease || currentSemanticVersion < latestVersion)) |
|
|
|
{ |
|
|
|
Logger.LogInformation("Updating package \"{0}\" from v{1} to v{2}.", packageId, currentSemanticVersion.ToString(), latestVersion.ToString()); |
|
|
|
versionAttribute.Value = latestVersion.ToString(); |
|
|
|
|