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

Bump required SDK to 8+ and remove fixed issues #52

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageOutputPath Condition="'$(Build_ArtifactStagingDirectory)' != ''">
$(Build_ArtifactStagingDirectory)\packages\</PackageOutputPath>
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)packages\</PackageOutputPath>
<SourceLinkPackageVersion>8.0.0</SourceLinkPackageVersion>
<NerdbankPackageVersion>3.6.133</NerdbankPackageVersion>

<!-- Packaging properties -->
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
<Description>Enables reproducible build settings</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="$(SourceLinkPackageVersion)" />
<PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="$(SourceLinkPackageVersion)" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="$(SourceLinkPackageVersion)" />
<PackageReference Include="Microsoft.SourceLink.GitLab" Version="$(SourceLinkPackageVersion)" />
</ItemGroup>

<ItemGroup>
<None Include="DotNet.ReproducibleBuilds.props" Pack="true" PackagePath="build/" />
<None Include="DotNet.ReproducibleBuilds.targets" Pack="true" PackagePath="build/" />
Expand Down
19 changes: 5 additions & 14 deletions src/DotNet.ReproducibleBuilds/DotNet.ReproducibleBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
<PropertyGroup>
<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl Condition=" '$(PublishRepositoryUrl)' == '' ">true</PublishRepositoryUrl>

<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources Condition=" '$(EmbedUntrackedSources)' == '' ">true</EmbedUntrackedSources>

<!-- Enable WPF projects to process package references so source link works
We only need this enabled for 5.0 SDKs; 6.0 defaults to it on.
-->
<IncludePackageReferencesDuringMarkupCompilation
Condition=" '$(IncludePackageReferencesDuringMarkupCompilation)' == '' and '$(BundledNETCoreAppTargetFrameworkVersion)' == '5.0' " >true</IncludePackageReferencesDuringMarkupCompilation>
</PropertyGroup>

<PropertyGroup Condition="'$(RepositoryBranch)' == '' and '$(PublishRepositoryUrl)' == 'true'">
Expand Down Expand Up @@ -43,13 +34,13 @@
</PropertyGroup>

<PropertyGroup>
<_ReproducibleBuildsMSBuildMinVersion>16.10.0</_ReproducibleBuildsMSBuildMinVersion>
<_ReproducibleBuildsMSBuildMinVersion>17.8.0</_ReproducibleBuildsMSBuildMinVersion>
<_ReproducibleBuildsMSBuildVersion>$(MSBuildVersion)</_ReproducibleBuildsMSBuildVersion><!-- Store in a non-reserved property for testing -->
MattKotsenas marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<Target Name="_ReproducibleBuildsMSBuildVersionCheck"
Condition=" '$([System.Version]::Parse($(_ReproducibleBuildsMSBuildMinVersion)).CompareTo($([System.Version]::Parse($(MSBuildVersion)))))' &gt; '0' "
BeforeTargets="ResolveAssemblyReferences;Build;Rebuild" >
<Warning
Text = "Reproducible builds require MSBuild '$(_ReproducibleBuildsMSBuildMinVersion)' or later. This project is using '$(MSBuildVersion)'. Use .NET SDK 5.0.300 or VS 16.10 or later." />
Condition="$([MSBuild]::VersionLessThan($(_ReproducibleBuildsMSBuildVersion), $(_ReproducibleBuildsMSBuildMinVersion)))"
BeforeTargets="ResolveAssemblyReferences;Build;Rebuild">
<Warning Text="Reproducible builds requires MSBuild '$(_ReproducibleBuildsMSBuildMinVersion)' or later. This project is using '$(_ReproducibleBuildsMSBuildVersion)'. Use .NET SDK 8.0.100 or VS 17.8 or later." />
</Target>
</Project>
26 changes: 26 additions & 0 deletions tests/DotNet.ReproducibleBuilds.Tests/MinimumVersionTests.cs
Original file line number Diff line number Diff line change
@@ -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<string, string> 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);
}
}