Skip to content
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

This file was deleted.

1 change: 0 additions & 1 deletion docs/Reproducible-MSBuild/Techniques/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
- [DisableImplicitNuGetFallbackFolder](./DisableImplicitNuGetFallbackFolder.md)
- [DisableImplicitLibraryPacksFolder](./DisableImplicitLibraryPacksFolder.md)
- [DOTNET_MULTILEVEL_LOOKUP](./DOTNET_MULTILEVEL_LOOKUP.md)
- [NetCoreTargetingPackRoot](./NetCoreTargetingPackRoot.md)
- [NUGET_XMLDOC_MODE](./NUGET_XMLDOC_MODE.md)
- [TargetFrameworkRootPath](./TargetFrameworkRootPath.md)
8 changes: 0 additions & 8 deletions src/DotNet.ReproducibleBuilds.Isolated/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
Text="Error, TargetFrameworkRootPath not initialized. If you're building for net462 or any other version of desktop NETFramework, please reference the 'Microsoft.NETFramework.ReferenceAssemblies' nuget package and run restore on the project to fix up your framework reference paths." />
</Target>

<!--
Disable msbuild's lookup of dotnetcore, dotnet5+ framework reference assemblies through default install
locations. Instead, resolve from nuget feed.
-->
<PropertyGroup>
<NetCoreTargetingPackRoot>[UNDEFINED]</NetCoreTargetingPackRoot>
</PropertyGroup>

<!--
Disable the extra implicit nuget package caches provided by dotnetsdk.
-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using DotNet.ReproducibleBuilds.Tests.Shared;

using FluentAssertions;

using Microsoft.Build.Utilities.ProjectCreation;

namespace DotNet.ReproducibleBuilds.Isolated.Tests;

public class IsolatedProjectTests : TestBase
{
[Fact]
public void ProjectCanRestore()
{
ProjectCreator.Templates
.ReproducibleBuildsIsolatedProject(GetRandomFile(".csproj"), configureProject: project =>
{
project.Property("TargetFramework", GetCurrentTargetFrameworkMoniker());
})
.TryRestore(out bool result, out BuildOutput output);

output.Errors.Should().HaveCount(0);
output.Warnings.Should().HaveCount(0);
result.Should().BeTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void RespectsSetValue(bool? value, string expected)
using EnvironmentVariableSuppressor hostSuppressor = new("TF_BUILD"); // Suppress our own CI provider variables (i.e. Azure DevOps)

ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.PropertyGroup()
.Property(ContinuousIntegrationBuild, value?.ToLowerInvariant())
.Project
Expand All @@ -34,14 +34,14 @@ public void RespectsGlobalProperties(Dictionary<string, string> envVars)

// If ContinuousIntegrationBuild is not set, it should be set from the CI provider property
ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.ProjectWithGlobalProperties(envVars)
.GetPropertyValue(ContinuousIntegrationBuild)
.Should().Be(true.ToLowerInvariant());

// If ContinuousIntegrationBuild is set, it should take precedence over the CI provider variables
ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.ProjectWithGlobalProperties(envVars.With(ContinuousIntegrationBuild, false.ToLowerInvariant()))
.GetPropertyValue(ContinuousIntegrationBuild)
.Should().Be(false.ToLowerInvariant(), "because explicitly setting `ContinuousIntegrationBuild` should always win.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void BelowMinimumVersionEmitsWarning(string msbuildVersion, bool success,
};

ProjectCreator project = ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"));
.ReproducibleBuildsProject(GetRandomFile(".csproj"));

if (suppress)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/DotNet.ReproducibleBuilds.Tests/ProjectTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class ProjectTemplates
{
private static readonly string ThisAssemblyDirectory = Path.GetDirectoryName(typeof(ProjectTemplates).Assembly.Location)!;

public static ProjectCreator ReproducibleBuildProject(this ProjectCreatorTemplates templates, FileInfo project)
public static ProjectCreator ReproducibleBuildsProject(this ProjectCreatorTemplates templates, FileInfo project)
{
DirectoryInfo directory = project.Directory ?? throw new ArgumentException("Project's path does not appear to have a parent.", nameof(project));

Expand All @@ -26,6 +26,6 @@ public static ProjectCreator ReproducibleBuildProject(this ProjectCreatorTemplat
ProjectCollection projectCollection = new(); // Create a new collection for each project to ensure environment variables aren't shared between tests

return templates
.SdkCsproj(path: project.FullName, targetFramework: "net9.0", projectCollection: projectCollection);
.SdkCsproj(path: project.FullName, targetFramework: "net8.0", projectCollection: projectCollection);
}
}
8 changes: 4 additions & 4 deletions tests/DotNet.ReproducibleBuilds.Tests/SourceLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SourceLinkTests : TestBase
public void PublishRepositoryUrlIsSet(bool? publishRepositoryUrl, bool expected)
{
ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.PropertyGroup()
.Property("PublishRepositoryUrl", publishRepositoryUrl.ToLowerInvariant())
.Project
Expand All @@ -29,7 +29,7 @@ public void PublishRepositoryUrlIsSet(bool? publishRepositoryUrl, bool expected)
public void DebugTypeIsSet(string? debugType, string expected)
{
ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.PropertyGroup()
.Property("DebugType", debugType)
.Project
Expand All @@ -44,7 +44,7 @@ public void DebugTypeIsSet(string? debugType, string expected)
public void EmbedUntrackedSourcesIsSet(bool? embedUntrackedSources, bool expected)
{
ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.PropertyGroup()
.Property("PublishRepositoryUrl", embedUntrackedSources.ToLowerInvariant())
.Project
Expand All @@ -60,7 +60,7 @@ public void RepositoryBranchIsSet(Dictionary<string, string?> env, string expect
using IDisposable ciSuppressors = env.Select(kvp => new EnvironmentVariableSuppressor(kvp.Key)).ToDisposable(); // Suppress the mock CI provider (just in case)

ProjectCreator project = ProjectCreator.Templates
.ReproducibleBuildProject(GetRandomFile(".csproj"))
.ReproducibleBuildsProject(GetRandomFile(".csproj"))
.PropertyGroup()
.Properties(env);

Expand Down
15 changes: 15 additions & 0 deletions tests/Shared/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ public void Dispose()
GC.SuppressFinalize(this);
}

protected string GetCurrentTargetFrameworkMoniker()
{
#if NETFRAMEWORK
return "net472";
#elif NET8_0
return "net8.0";
#elif NET9_0
return "net9.0";
#elif NET10_0
return "net10.0";
#else
throw new NotSupportedException("Unsupported target framework.");
#endif
}

protected virtual void Dispose(bool isDisposing)
{
TestRootPath.Refresh();
Expand Down