Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tools]Remove the logic to update psd1 in artifacts. #15057

Merged
merged 2 commits into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions tools/VersionController/Models/VersionBumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void BumpAllVersions()
UpdateOutputModuleManifest(releaseNotes);
UpdateRollupModuleManifest();
UpdateAssemblyInfo();
UpdateDependentModules();
Console.WriteLine("Finished bumping version " + moduleName + "\n");
}

Expand Down Expand Up @@ -405,52 +404,6 @@ private void UpdateChangeLog()
File.WriteAllLines(changeLogPath, newFile);
}

/// <summary>
/// Update the ModuleVersion of the bumped module in any dependent module's RequiredModule field.
/// </summary>
private void UpdateDependentModules()
{
var moduleName = _fileHelper.ModuleName;
var projectDirectories = _fileHelper.ProjectDirectories;
var outputDirectories = _fileHelper.OutputDirectories;
foreach (var projectDirectory in projectDirectories)
{
var moduleManifestPaths = Directory.GetFiles(projectDirectory, "*.psd1", SearchOption.AllDirectories)
.Where(f => !f.Contains("Netcore") &&
!f.Contains("bin") &&
!f.Contains("dll-Help") &&
!ModuleFilter.IsAzureStackModule(f))
.ToList();
foreach (var moduleManifestPath in moduleManifestPaths)
{
var file = File.ReadAllLines(moduleManifestPath);
var pattern = @"ModuleName(\s*)=(\s*)(['\""])" + moduleName + @"(['\""])(\s*);(\s*)ModuleVersion(\s*)=(\s*)(['\""])" + _oldVersion + @"(['\""])";
if (file.Where(l => Regex.IsMatch(l, pattern)).Any())
{
var updatedFile = file.Select(l => Regex.Replace(l, pattern, "ModuleName = '" + moduleName + "'; ModuleVersion = '" + _newVersion + "'"));
File.WriteAllLines(moduleManifestPath, updatedFile);
var updatedModuleName = Path.GetFileNameWithoutExtension(moduleManifestPath);
foreach (var outputDirectory in outputDirectories)
{
var outputModuleDirectory = Directory.GetDirectories(outputDirectory, updatedModuleName).FirstOrDefault();
if (outputModuleDirectory == null)
{
continue;
}

var outputModuleManifestPath = Directory.GetFiles(outputModuleDirectory, updatedModuleName + ".psd1").FirstOrDefault();
if (outputModuleManifestPath == null)
{
continue;
}

File.WriteAllLines(outputModuleManifestPath, updatedFile);
}
}
}
}
}

/// <summary>
/// Check whether or not the given module is new by searching for past entries in the change log.
/// </summary>
Expand Down