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

Kuinox.NupkgDeterministicator.MSBuild package #2

Open
BinToss opened this issue Aug 24, 2024 · 3 comments · May be fixed by #5
Open

Kuinox.NupkgDeterministicator.MSBuild package #2

BinToss opened this issue Aug 24, 2024 · 3 comments · May be fixed by #5

Comments

@BinToss
Copy link
Contributor

BinToss commented Aug 24, 2024

I've been struggling to make an MSBuild target that runs after "Pack" to automatically determinize the package and symbols package and came to the realization that a MSBuild Target wrapper for a .NET CLI tool is silly. Although I've finished that Target, it is designed to Error if Kuinox.NupkgDeterministicator is not installed globally nor locally. That is inconvenient.


Kuinox.NupkgDeterministicator.MSBuild

An AfterTargets="Pack" Target so dotnet/msbuild determinizes the nupkg (and .symbols.nupkg or .snupkg if '$(IncludeSymbols)' == 'true')

This proposal may need a 'core' project of functionality common to both Kuinox.NupkgDeterministicator and Kuinox.NupkgDeterministicator.MSBuild.

The project for this package should set the little-known (and arguably poorly-implemented) `true property so the package is not included in build output and is never used as a transitive dependency. It may be more convenient for version/release management if it's put into its own repository

Target inputs

Inputs Values/Types Default Usage
Deterministic 'true'/'false'/'' 'true' If true, run NupkgDeterministicator on the nupkg and snupkg (if applicable)
PackageOutputPath string '$(OutputPath)' The directory in which the package was created
PackageId string '$(AssemblyName)' Used to identify the nupkg and symbols package
PackageVersion string '$(Version)' Used to identify the nupkg and symbols package
IncludeSymbols 'true'/'false'/'' '' (falsey) If true, deterministicate the symbols package
SymbolPackageFormat 'symbols.nupkg'/'snupkg' 'symbols.nupkg' (legacy) Used to identify the symbols package

None of these properties are specific to this target—they are existing properties used by Build or Pack.

Conditions/Rules

Some sanity checks are already performed by Pack and its dependency targets.

// csharp pseudocode
if (Deterministic)
{
  var nupkgFullPath = Path.Join(PackageOutputPath, $"{PackageId}.{PackageVersion}.nupkg");
  var nupkgSymFullPath = Path.Join(PackageOutputPath, $"{PackageId}.{PackageVersion}.{SymbolPackageFormat}");
  Deterministicate(nupkgFullPath)
  if (IncludeSymbols)
    Deterministicate(nupkgSymFullPath)
}
@BinToss
Copy link
Contributor Author

BinToss commented Aug 24, 2024

This one's a doozy. I'll help out.

@Kuinox
Copy link
Owner

Kuinox commented Aug 24, 2024

I have been working on a msbuild task for another project so I have everything fresh to make this.
https://github.com/Kuinox/Mocker

@Kuinox
Copy link
Owner

Kuinox commented Aug 25, 2024

MSBuild Target wrapper for a .NET CLI tool is silly

Well, not really ! Sure for a dotnet tool, that's not ideal, but afaik, the common recommended way is to ship the dll with the task.

@Kuinox Kuinox linked a pull request Aug 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants