Skip to content

Commit

Permalink
🐛Fix potential problem cleaning before restoring .NET projects
Browse files Browse the repository at this point in the history
  • Loading branch information
pleonex committed Nov 18, 2023
1 parent 6866508 commit 590326d
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/Cake.Frosting.PleOps.Recipe/Dotnet/RestoreDependenciesTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ public class RestoreDependenciesTask : FrostingTask<PleOpsBuildContext>
/// <inheritdoc />
public override void Run(PleOpsBuildContext context)
{
if (!context.IsIncrementalBuild) {
context.Log.Information("Cleaning .NET projects for selected configuration and platform");
var cleanSettings = new DotNetCleanSettings {
Verbosity = context.DotNetContext.ToolingVerbosity,
Configuration = context.DotNetContext.Configuration,
MSBuildSettings = new DotNetMSBuildSettings()
.WithProperty("Platform", context.DotNetContext.Platform),
};
context.DotNetClean(context.DotNetContext.SolutionPath, cleanSettings);
}

MSBuildTreatAllWarningsAs warningMode = context.WarningsAsErrors
? MSBuildTreatAllWarningsAs.Error
: MSBuildTreatAllWarningsAs.Default;
Expand All @@ -64,5 +53,19 @@ public override void Run(PleOpsBuildContext context)
}

context.DotNetRestore(context.DotNetContext.SolutionPath, dotnetSettings);

// Clean must happen after restore, otherwise it may fail
// https://github.com/dotnet/sdk/issues/4018
// https://github.com/dotnet/sdk/issues/30199
if (!context.IsIncrementalBuild) {
context.Log.Information("Cleaning .NET projects for selected configuration and platform");
var cleanSettings = new DotNetCleanSettings {
Verbosity = context.DotNetContext.ToolingVerbosity,
Configuration = context.DotNetContext.Configuration,
MSBuildSettings = new DotNetMSBuildSettings()
.WithProperty("Platform", context.DotNetContext.Platform),
};
context.DotNetClean(context.DotNetContext.SolutionPath, cleanSettings);
}
}
}

0 comments on commit 590326d

Please sign in to comment.