-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support NuGet lockfiles (Updated) (#9678)
* Ignore VSCode C# Dev Kit * Add rb logic for nuget lock file * Add cs logic to handle nuget lock files * Some fixes in nuget file_updater.rb * Fix file_fetcher * fixed fetch_files * Update lock files as part of project updates instead of directly updating them * MSBuildHelper.SidelineGlobalJsonAsync * Update LockFileUpdater.cs --------- Co-authored-by: AbdulFattaah Popoola <[email protected]>
- Loading branch information
1 parent
de37efa
commit 08f2675
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ coverage/ | |
spoom_data/ | ||
spoom_report.html | ||
.vs/ | ||
# Ignore VSCode C# Dev Kit | ||
**/.mono/**/values.xml |
28 changes: 28 additions & 0 deletions
28
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace NuGetUpdater.Core; | ||
|
||
internal static class LockFileUpdater | ||
{ | ||
public static async Task UpdateLockFileAsync( | ||
string repoRootPath, | ||
string projectPath, | ||
Logger logger) | ||
{ | ||
var projectDirectory = Path.GetDirectoryName(projectPath); | ||
var lockPath = Path.Combine(projectDirectory, "packages.lock.json"); | ||
logger.Log($" Updating lock file"); | ||
if (!File.Exists(lockPath)) | ||
{ | ||
logger.Log($" File [{Path.GetRelativePath(repoRootPath, lockPath)}] does not exist."); | ||
return; | ||
} | ||
|
||
await MSBuildHelper.SidelineGlobalJsonAsync(projectDirectory, repoRootPath, async () => | ||
{ | ||
var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("dotnet", $"restore --force-evaluate {projectPath}", workingDirectory: projectDirectory); | ||
if (exitCode != 0) | ||
{ | ||
logger.Log($" Lock file update failed.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}"); | ||
} | ||
}, retainMSBuildSdks: true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters