GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[Bug] -output file -outputfile gitversion.json exited with code 1.

Open ucapbba opened this issue 3 years ago • 6 comments

Description of issue

I have added GitVersion.MsBuild.5.8.1to my GUI.csproj (contained in a Visual Studio 2017 solution with many projects). My .yml contains the line run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} which is run after push. Having added GitVersion I see (full paths reduced):

   "D:\a\GUI\GUI.csproj" (default target) (2) ->
   (RunGitVersion target) -> 
     D:\a\packages\GitVersion.MsBuild.5.8.1\tools\GitVersion.MsBuild.targets(9,9): error MSB3073: The command ""D:\a\packages\GitVersion.MsBuild.5.8.1\tools\net48/gitversion.exe" "D:\a\GUI" -output file -outputfile gitversion.json" exited with code 1. [D:\a\GUI\GUI.csproj]

Analysis

The line where error occurs in GitVersion.MsBuild.target is

Exec Command="$(GitVersionFileExe) "$(MSBuildProjectDirectory)" $(GitVersion_ToolArgments)"

I add my gitversion.json which appeared in my project folder after local build (I also tried adding to source control but I guess not required) , and my msbuild.yml and GUI.csproj used here:

gitversion - Copy.json.txt msbuild - Copy.yml.txt GUI - Copy.csproj.txt

Context

This is the first time I have used GitVersion. I installed using NuGet package and removed AssemblyInfo.cs from the .csproj. The repository is private, if useful I can add a user to assist.

I have been following here to try to understand the issue https://gitversion.net/docs/usage/msbuild

Your Environment

VS 2017 / Net 4.8 / Windows 10 / GitVersion.MsBuild.5.8.1

Thankyou

ucapbba avatar Feb 12 '22 11:02 ucapbba

Can you please try the command line instead? If it too fails, it may be easier to figure out why.

asbjornu avatar Feb 14 '22 10:02 asbjornu

running dotnet-gitversion from my .git location I get image which looks reasonable.

I re-added my AssemblyInfo.cs and ran dotnet-gitversion /updateassemblyinfo and my AssemblyInfo.cs is updated with

[assembly: AssemblyInformationalVersion("0.1.0-FRAN-90-Jenkins.1+314.Branch.FRAN-90-Jenkins.Sha.e09f43344ed471e1ae810288e0527a946f86383c")]

I then ran the line from the build error in command line Path\packages\GitVersion.MsBuild.5.8.1\tools\net48/gitversion.exe Path\GUI -output file -outputfile gitversion.json and do not receive any error so it seems to be something to do with the msbuild.yml

ucapbba avatar Feb 18 '22 17:02 ucapbba

Yeah, looks like GitVersion itself is working fine. If there's something wrong with msbuild.yml, that's out of scope for GitVersion, sorry.

asbjornu avatar Feb 18 '22 21:02 asbjornu

Perhaps it's related to this case : https://github.com/GitTools/GitVersion/issues/2534

the slash seems to be the wrong way before gitversion.exe \net48/gitversion.exe so perhaps the error is due to not being able to find GitVersion.exe in the GitAction

ucapbba avatar Feb 19 '22 08:02 ucapbba

I have replicated the case with a very simple test project https://github.com/ucapbba/CodeSamples/tree/main/GitAction and workflow https://github.com/ucapbba/CodeSamples/tree/main/.github/workflows

It is the default "Hello World" .csproj in visual studio which uses the default MSBuild git action from GitHub and uses the GitVersion.MSBuild NuGet Package. You can see exactly what has been done and replicate the error with a push to main or PR to GitVersion branch

ucapbba avatar Feb 19 '22 09:02 ucapbba

@ucapbba, for GitVersion to execute successfully, it needs the full repository history. By default, actions/checkout does a shallow clone. Add the following to the workflow and it should at least be able to execute:

    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

This requirement is documented.

asbjornu avatar Mar 03 '22 22:03 asbjornu

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

github-actions[bot] avatar Apr 04 '23 11:04 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

github-actions[bot] avatar May 05 '23 11:05 github-actions[bot]