-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: Add validator to check .NET SDK as minimum requirements #3194
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,52 +148,52 @@ public Task<DotNetCliCommandResult> PublishNoRestoreAsync(CancellationToken canc | |
| cancellationToken); | ||
|
|
||
| internal static string GetRestoreCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string filePath, string? extraArguments = null, string? binLogSuffix = null, bool excludeOutput = false) | ||
| => new StringBuilder() | ||
| => new StringBuilder(256) | ||
| .AppendArgument("restore") | ||
| .AppendArgument($"\"{filePath}\"") | ||
| .AppendArgument($"\"{filePath.ToRelativePath(artifactsPaths)}\"") | ||
| // restore doesn't support -f argument. | ||
| .AppendArgument(artifactsPaths.PackagesDirectoryName.IsBlank() ? string.Empty : $"--packages \"{artifactsPaths.PackagesDirectoryName}\"") | ||
| .AppendArgument(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver)) | ||
| .AppendArgument(extraArguments) | ||
| .AppendArgument(GetMandatoryMsBuildSettings(buildPartition.BuildConfiguration)) | ||
| .AppendArgument(GetMsBuildBinLogArgument(buildPartition, binLogSuffix)) | ||
| .MaybeAppendOutputPaths(artifactsPaths, true, excludeOutput) | ||
| .MaybeAppendExtraArguments(artifactsPaths, isRestore: true, excludeOutput: excludeOutput) | ||
| .ToString(); | ||
|
|
||
| internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string filePath, string tfm, string? extraArguments = null, string? binLogSuffix = null, bool excludeOutput = false) | ||
| => new StringBuilder() | ||
| => new StringBuilder(256) | ||
| .AppendArgument("build") | ||
| .AppendArgument($"\"{filePath}\"") | ||
| .AppendArgument($"\"{filePath.ToRelativePath(artifactsPaths)}\"") | ||
| .AppendArgument($"-f {tfm}") | ||
| .AppendArgument($"-c {buildPartition.BuildConfiguration}") | ||
| .AppendArgument(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver)) | ||
| .AppendArgument(extraArguments) | ||
| .AppendArgument(GetMandatoryMsBuildSettings(buildPartition.BuildConfiguration)) | ||
| .AppendArgument(artifactsPaths.PackagesDirectoryName.IsBlank() ? string.Empty : $"/p:NuGetPackageRoot=\"{artifactsPaths.PackagesDirectoryName}\"") | ||
| .AppendArgument(GetMsBuildBinLogArgument(buildPartition, binLogSuffix)) | ||
| .MaybeAppendOutputPaths(artifactsPaths, excludeOutput: excludeOutput) | ||
| .MaybeAppendExtraArguments(artifactsPaths, isBuild: true, excludeOutput: excludeOutput) | ||
| .ToString(); | ||
|
|
||
| internal static string GetPublishCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string filePath, string tfm, string? extraArguments = null, string? binLogSuffix = null) | ||
| => new StringBuilder() | ||
| => new StringBuilder(256) | ||
| .AppendArgument("publish") | ||
| .AppendArgument($"\"{filePath}\"") | ||
| .AppendArgument($"\"{filePath.ToRelativePath(artifactsPaths)}\"") | ||
| .AppendArgument($"-f {tfm}") | ||
| .AppendArgument($"-c {buildPartition.BuildConfiguration}") | ||
| .AppendArgument(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver)) | ||
| .AppendArgument(extraArguments) | ||
| .AppendArgument(GetMandatoryMsBuildSettings(buildPartition.BuildConfiguration)) | ||
| .AppendArgument(artifactsPaths.PackagesDirectoryName.IsBlank() ? string.Empty : $"/p:NuGetPackageRoot=\"{artifactsPaths.PackagesDirectoryName}\"") | ||
| .AppendArgument(GetMsBuildBinLogArgument(buildPartition, binLogSuffix)) | ||
| .MaybeAppendOutputPaths(artifactsPaths) | ||
| .MaybeAppendExtraArguments(artifactsPaths, isPublish: true) | ||
| .ToString(); | ||
|
|
||
| private static string GetMsBuildBinLogArgument(BuildPartition buildPartition, string? suffix) | ||
| { | ||
| if (!buildPartition.GenerateMSBuildBinLog || suffix.IsBlank()) | ||
| return string.Empty; | ||
|
|
||
| return $"\"-bl:{buildPartition.ProgramName}-{suffix}.binlog\""; | ||
| return $"-bl:\"{buildPartition.ProgramName}-{suffix}.binlog\""; | ||
| } | ||
|
|
||
| private static string GetCustomMsBuildArguments(BenchmarkCase benchmarkCase, IResolver resolver) | ||
|
|
@@ -228,18 +228,37 @@ internal static class DotNetCliCommandExtensions | |
| // We force the project to output binaries to a new directory. | ||
| // Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path), | ||
| // so we don't include it if we're building no-deps (only supported for integration tests). | ||
| internal static StringBuilder MaybeAppendOutputPaths(this StringBuilder stringBuilder, ArtifactsPaths artifactsPaths, bool isRestore = false, bool excludeOutput = false) | ||
| => excludeOutput | ||
| ? stringBuilder | ||
| : stringBuilder | ||
| // Use AltDirectorySeparatorChar so it's not interpreted as an escaped quote `\"`. | ||
| // Use a subdirectory for ArtifactsPath so that DefaultItemExcludes (which the SDK | ||
| // sets to $(ArtifactsPath)/**) doesn't cover project-level files like wwwroot/. | ||
| .AppendArgument($"/p:ArtifactsPath=\"{artifactsPaths.BuildArtifactsDirectoryPath}{Path.AltDirectorySeparatorChar}.artifacts{Path.AltDirectorySeparatorChar}\"") | ||
| .AppendArgument($"/p:OutDir=\"{artifactsPaths.BinariesDirectoryPath}{Path.AltDirectorySeparatorChar}\"") | ||
| // OutputPath is legacy, per-project version of OutDir. We set both just in case. https://github.com/dotnet/msbuild/issues/87 | ||
| .AppendArgument($"/p:OutputPath=\"{artifactsPaths.BinariesDirectoryPath}{Path.AltDirectorySeparatorChar}\"") | ||
| .AppendArgument($"/p:PublishDir=\"{artifactsPaths.PublishDirectoryPath}{Path.AltDirectorySeparatorChar}\"") | ||
| .AppendArgument(isRestore ? string.Empty : $"--output \"{artifactsPaths.BinariesDirectoryPath}{Path.AltDirectorySeparatorChar}\""); | ||
| internal static StringBuilder MaybeAppendExtraArguments( | ||
| this StringBuilder stringBuilder, | ||
| ArtifactsPaths artifactsPaths, | ||
| bool isRestore = false, | ||
| bool isBuild = false, | ||
| bool isPublish = false, | ||
| bool excludeOutput = false) | ||
| { | ||
| if (!excludeOutput) | ||
| { | ||
| // Use a subdirectory for ArtifactsPath so that DefaultItemExcludes (which the SDK | ||
| // sets to $(ArtifactsPath)/**) doesn't cover project-level files like wwwroot/. | ||
| stringBuilder.AppendArgument($"--artifacts-path .artifacts"); | ||
|
|
||
| if (!isRestore) | ||
| stringBuilder.AppendArgument($"--output \"{artifactsPaths.BinariesDirectoryPath.ToRelativePath(artifactsPaths)}\""); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we don't need to pass
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also agree Though, it will be handled on another PR.
Instead, following steps are expected.
|
||
| } | ||
|
|
||
| if (isPublish) | ||
| stringBuilder.AppendArgument($"/p:PublishDir=\"{artifactsPaths.PublishDirectoryPath}\""); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can also omit
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So it seems better to use fixed path that relative to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems the same issue with non-publishing toolchains for the bin directory. If we're removing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we could also add
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It'll be expected to be handled on another PR.
I'll create another PR to supports custom Additionally,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Let's just include the full fix in a single PR, please. |
||
|
|
||
| return stringBuilder; | ||
| } | ||
|
|
||
| internal static string ToRelativePath(this string path, ArtifactsPaths artifactsPaths) | ||
| { | ||
| var buildArtifactsDirectoryPath = $"{artifactsPaths.BuildArtifactsDirectoryPath}{Path.DirectorySeparatorChar}"; | ||
| if (path.StartsWith(buildArtifactsDirectoryPath)) | ||
| return path.Substring(buildArtifactsDirectoryPath.Length); | ||
|
|
||
| return path; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter is being added for API consistency between commands.
It'll be removed on another PR if it's not expected to be used.