GitTools/GitVersion

[ISSUE]: Cannot pack on 6.0.0

MeikelLP opened this issue · 9 comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.MsBuild

GitVersion version

6.0.0

Operating system

Linux

What are you seeing?

dotnet pack /src/MyLib/MyLib.csproj
  Possible reasons for this include:
    * You misspelled a built-in dotnet command.
    * You intended to execute a .NET program, but dotnet---roll-forward does not exist.
    * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
  Could not execute because the specified command or file was not found.
/home/some-user/.nuget/packages/gitversion.msbuild/6.0.0/tools/GitVersion.MsBuild.targets(21,9): error MSB3073: The command "dotnet --roll-forward Major "/home/some-user/.nuget/packages/gitversion.msbuild/6.0.0/tools/gitversion.dll" "/src/MyLib"  -output file -outputfile "obj/gitversion.json"" exited with code 1. [/src/MyLib/MyLib.csproj]

⚠️ Paths are masked

What is expected?

No Exception

Steps to Reproduce

I guess:

  • Use TargetFrameworks => net6.0;net8.0
  • Use GitVersion.MsBuild => 6.0.0

I first had an issue with dotnet build when referencing netstandard2.0 but that's been deprecated: #4075
After removing that target framework the build was successful but not the dotnet pack command

Sadly I cannot share the source code of my repo

Workaround:

  • Use GitVersion.MsBuild => 5.12.0

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

Same issue here with net8.0, GitVersion.MsBuild => 6.0.0 and the command dotnet build --configuration Release --output publish... 5.12.0 works within our build pipeline.

I am getting the same error in azure devops pipeline using version 6.0.0

The command "dotnet --roll-forward Major "/home/vsts/.nuget/packages/gitversion.msbuild/6.0.0/tools/net7.0/gitversion.dll" "/home/vsts/work/1/s/src/Engine" -output file -outputfile "obj/gitversion.json"" exited with code 1.

@mihaimyh the reason it's not working for you is because it's searching for net7.0 within the contents of the nuget package, but we do not bundle the net7.0 anymore as it's obsolete, https://nuget.info/packages/GitVersion.MsBuild/6.0.0 (check the tools folder)

@MeikelLP here is a configuration that can help you with dotnet pack:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net8.0;net6.0</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <GitVersionTargetFramework>net6.0</GitVersionTargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="GitVersion.MsBuild" Version="6.0.2">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

</Project>

There is a property that you can explicitly set <GitVersionTargetFramework>net8.0</GitVersionTargetFramework>
That will force the dotnet pack to use version 8.0 for version calculation.

@arturcic For now I will stay on 5.X until this is fixed

The main argument I sold my team this tool with was that it requires no config and works out of the box by just installing 1 dependency. Which this bug is preventing

@arturcic This is just a workaround, not a solution... (Although it works in our case)

Yes I know, if you help finding a better solution and not a workaround that would be much appreciated. At this point I don't have enough time to invest in this

Same exact error with v6.0.2 on projects which target only netstandard2.1, the workaround in my case was to set GitVersionTargetFramework to net6.0 or net8.0.

In my case, the error is that dotnet 6 is used instead of dotnet 8:

$ dotnet build --configuration Release --output publish/
  Determining projects to restore...
  Restored /builds/dummy.csproj (in 238 ms).
  Possible reasons for this include:
    * You misspelled a built-in dotnet command.
    * You intended to execute a .NET program, but dotnet---roll-forward does not exist.
    * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
  Could not execute because the specified command or file was not found.
/root/.nuget/packages/gitversion.msbuild/6.0.0/tools/GitVersion.MsBuild.targets(21,9): error MSB3073: The command "dotnet --roll-forward Major "/root/.nuget/packages/gitversion.msbuild/6.0.0/tools/net7.0/gitversion.dll" "/builds/dummy"  -output file -outputfile "obj/gitversion.json"" exited with code 1. [/builds/dummy.csproj]
Build FAILED.
/root/.nuget/packages/gitversion.msbuild/6.0.0/tools/GitVersion.MsBuild.targets(21,9): error MSB3073: The command "dotnet --roll-forward Major "/root/.nuget/packages/gitversion.msbuild/6.0.0/tools/net7.0/gitversion.dll" "/builds/dummy"  -output file -outputfile "obj/gitversion.json"" exited with code 1. [/builds/dummy.csproj]
    0 Warning(s)
    1 Error(s)
Time Elapsed 00:00:01.88
ERROR: Job failed: exit code 1