From 714df2e17493c71d0db054727f62a82810eeac7d Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Fri, 6 Sep 2024 12:08:18 -0700 Subject: [PATCH] Bump required SDK to 8+ and remove fixed issues (#52) Bump the minimum required version of MSBuild to 17.8.0, which corresponds to .NET SDK 8, which will soon be oldest supported version of the SDK (see https://learn.microsoft.com/en-us/dotnet/core/porting/versioning-sdk-msbuild-vs). Doing so allows us to clean up / slim down the package: - Remove our references to SourceLink, since it's now provided by the SDK (reference: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/source-link) - Remove setting `` as it's already set to the same value by the SDK (reference: https://github.com/dotnet/sdk/pull/31632/files#diff-0adc92e620c2edfd1285b34be242429af4ff7116be50f6685b146b5c31a4de44R19) - Remove setting `` as it's already set to the same value by the SDK (reference: https://github.com/dotnet/sdk/pull/15465/files#diff-7d043b70287c061ddd2cc5ccc8ad0547b629b0eb9c60f3bce15b3b0f353744b9R26) I also added unit tests and updated docs. --- Directory.Build.props | 1 - README.md | 6 +---- .../DotNet.ReproducibleBuilds.csproj | 7 ----- .../DotNet.ReproducibleBuilds.targets | 19 ++++---------- .../MinimumVersionTests.cs | 26 +++++++++++++++++++ 5 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 tests/DotNet.ReproducibleBuilds.Tests/MinimumVersionTests.cs diff --git a/Directory.Build.props b/Directory.Build.props index 0746ad4..5094654 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,7 +10,6 @@ $(Build_ArtifactStagingDirectory)\packages\ $(MSBuildThisFileDirectory)packages\ - 8.0.0 3.6.133 diff --git a/README.md b/README.md index 913fccf..93fb517 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,10 @@ adding this package or manually as described here: https://devblogs.microsoft.co This package sets the following properties: - `PublishRepositoryUrl` = `true` -- `EmbedUntrackedSources` = `true` - `DebugType` = `embedded`. You can specify `portable` in your project if you prefer, but you'll need to upload that `.snupkg` file too. -- `IncludePackageReferencesDuringMarkupCompilation` = `true` (enables a fix for WPF) - `ContinuousIntegrationBuild` = `true` on CI systems -It also adds SourceLink dependencies for all repo types (the right one will be used automatically). - -For more information on debugging with Source Link is [here](https://devblogs.microsoft.com/dotnet/improving-debug-time-productivity-with-source-link/). +More information on `PublishRepositoryUrl` and debugging with Source Link is [here](https://devblogs.microsoft.com/dotnet/improving-debug-time-productivity-with-source-link/). ### Usage diff --git a/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.csproj b/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.csproj index 230b215..a1d8efc 100644 --- a/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.csproj +++ b/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.csproj @@ -11,13 +11,6 @@ Enables reproducible build settings - - - - - - - diff --git a/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.targets b/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.targets index 0e7acc3..7f501da 100644 --- a/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.targets +++ b/src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.targets @@ -2,15 +2,6 @@ true - - - true - - - true @@ -43,13 +34,13 @@ - <_ReproducibleBuildsMSBuildMinVersion>16.10.0 + <_ReproducibleBuildsMSBuildMinVersion>17.8.0 + <_ReproducibleBuildsMSBuildVersion>$(MSBuildVersion) - + Condition="$([MSBuild]::VersionLessThan($(_ReproducibleBuildsMSBuildVersion), $(_ReproducibleBuildsMSBuildMinVersion)))" + BeforeTargets="ResolveAssemblyReferences;Build;Rebuild"> + \ No newline at end of file diff --git a/tests/DotNet.ReproducibleBuilds.Tests/MinimumVersionTests.cs b/tests/DotNet.ReproducibleBuilds.Tests/MinimumVersionTests.cs new file mode 100644 index 0000000..964dba1 --- /dev/null +++ b/tests/DotNet.ReproducibleBuilds.Tests/MinimumVersionTests.cs @@ -0,0 +1,26 @@ +using FluentAssertions; +using Microsoft.Build.Utilities.ProjectCreation; + +namespace DotNet.ReproducibleBuilds.Tests; + +public class MinimumVersionTests : TestBase +{ + [Theory] + [InlineData("17.7.0", false)] + [InlineData("17.8.0", true)] + [InlineData("17.9.0", true)] + public void BelowMinimumVersionEmitsWarning(string msbuildVersion, bool success) + { + Dictionary globalProperties = new() + { + ["_ReproducibleBuildsMSBuildVersion"] = msbuildVersion + }; + + ProjectCreator.Templates + .ReproducibleBuildProject(GetRandomFile(".csproj")) + .TryBuild(restore: false, target: "_ReproducibleBuildsMSBuildVersionCheck", globalProperties, out bool result, out BuildOutput output); + + result.Should().BeTrue(); + output.Warnings.Should().HaveCount(success ? 0 : 1); + } +}