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

[Bug] dotnet pack fails on cold build with GitVersion.MsBuild and IsPackable=false #2815

Closed
cdonnellytx opened this issue Aug 17, 2021 · 3 comments · Fixed by #3115
Closed
Labels
Milestone

Comments

@cdonnellytx
Copy link

Describe the bug
dotnet pack will fail with a DirectoryNotFoundException when building a project that includes GitVersion.MsBuild and where IsPackable=false.

Expected Behavior

dotnet pack should succeed as if GitVersion.MsBuild was not there.

Actual Behavior

dotnet pack fails because GitVersion does not generate the GitVersionInformation.g.cs file:

C:\Users\cdonnelly\.nuget\packages\gitversion.msbuild\5.6.11\tools\GitVersion.MsBuild.targets(110,9): error : DirectoryNotFoundException: Could not find a part of the path 'D:\temp\marklar\obj\Debug\GitVersionInformation.g.cs'. [D:\temp\marklar\marklar.csproj]

Steps to Reproduce

  1. Clone https://github.com/cdonnellytx/GitVersionPackBug
  2. Run dotnet pack

Context

We are hitting this in a solution which contains a large number of NuGet packages and also includes their test projects, and in which we are importing GitVersion.MsBuild into all in a Directory.Build.props file.

The good news is I can easily work around this by adding an IsPackable check to my Include. The ideal path may be to just short-circuit out if IsPackable is false, but I don't know how this would affect a project with both NuGet and non-NuGet deployable packages that need versioning.

Your Environment

  • Windows 10 x64, Version 21H1 (OS Build 19043.1165)
  • .NET SDK 5.0.400 (x64)
  • GitVersion 5.6.11
  • Link to your project: https://github.com/cdonnellytx/GitVersionPackBug
  • Link to your CI build (if appropriate): The actual project and CI build are on an internal company GitHub Enterprise instance; the sample project replicates the bug in a much more minimalist fashion.
@asbjornu
Copy link
Member

Seems like you have an idea how to fix this. Pull requests are welcome! 🙏🏼

jpeirson pushed a commit to jpeirson/GitVersion that referenced this issue May 10, 2022
@jpeirson
Copy link

I've added a PR that fixes this by making GenerateGitVersionInformation create the intermediate dir if it doesn't exist: #3115

@arturcic arturcic added this to the 5.x milestone May 10, 2022
@arturcic arturcic modified the milestones: 5.x, 5.10.2 May 31, 2022
@arturcic
Copy link
Member

🎉 This issue has been resolved in version 5.10.3 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants