dotnet / reproducible-builds

Contains the DotNet.ReproducibleBuilds package
MIT License
168 stars 18 forks source link

Clarify the relationship between the two packages, and general usage #15

Open roji opened 2 years ago

roji commented 2 years ago

Reading the README.md, it isn't quite clear whether one should use both DotNet.ReproducibleBuilds and DotNet.ReproducibleBuilds.Isolated, or only one of them. What exactly each one of these packages does is also a bit vague, i.e. what exactly do I opt into for each one.

One last note: for DotNet.ReproducibleBuilds.Isolated, the usage says to include an <Sdk ... /> element in the csproj or Directory.Builds.props. A more complete sample would be useful here, since Sdk elements aren't something that's typically used, so it may not be immediately clear where to place them (inside an ? outside?).

cmeeren commented 1 year ago

Can someone explain how to use the <Sdk> element in the Directory.Build.props? I can't find any information about where to add this line from the readme:

<Sdk Name="DotNet.ReproducibleBuilds.Isolated" Version="{TBD}" />

If I add it as a child of <Project>, I just get this error when building the solution:

  MSBuild version 17.3.0+92e077650 for .NET
MSBUILD : error MSB1004: Specify the name of the target.
    Full command line: 'C:\Program Files\dotnet\sdk\6.0.400\MSBuild.dll /noconsolelogger /property:Configuration=Release /property:Platform=Any CPU /t: /logger:C:\<snip>\JetBrains.Platform.MsBuildEventLogger.dll;64863 /m:30 /fileLogger1 /fileloggerparameters1:LogFile=C:\<snip>\JetBrainsLog.ReSharperBuild_2022_08_18_20_13_51_6817.log; /fileLoggerParameters1:Verbosity=Normal C:\<snip>\MySolution.sln'
  Switches appended by response files:
Switch: /t:
For switch syntax, type "MSBuild -help"
baronfel commented 1 year ago

Hey folks!

There are some docs on how to reference SDKs in general on the MSBuild Docs site: https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2022

So I'd expect to see a project file or Directory.Build.props like:

<Project>
  <Sdk Name="Dotnet.ReproducibleBuilds.Isolated" Version="111" />
</Project>

@cmeeren for the specific build error, do you have a sample I can try to repro with locally?

Finally, I don't see anything in the props/targets files for the two packages that would prevent their use together. I'd need to dig deeper to be sure, though.

cmeeren commented 1 year ago

@baronfel You're right, my error was caused by Rider unloading the projects (without my noticing) when I made an erroneous change to Directory.Build.props, and there were then no projects to actually build.

It works with

<Project>

  <Sdk Name="DotNet.ReproducibleBuilds.Isolated" Version="1.1.1" />

  ...
hcoona commented 1 year ago

Checked the source code. I think

So we should use both of them together.