question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] GitVersion.MsBuild should not have 'runtime' listed in the IncludeAssets property

See original GitHub issue

Describe the bug When adding a nuget reference to GitVersion.MsBuild from Visual Studio in a Sdk-style project, we end up with this declaration:

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

Expected Behavior

The package should be restored like below (and maybe other assets need not be included…):

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

Actual Behavior

Having ‘runtime’ part of the included assets has some implications:

  • trough its dependency tree, GitVersion.MsBuild depends on System.Drawing.Common: image

  • This dependency (and others) end up in the build output and are listed in the deps.json file.

  • This is already not that clean, but then I have other issues when trying to run the application in docker:

  • I publish the application as framework-dependent and multi-platform and then build my Docker image

  • The application inside the Docker does not work and tells me it can’t find System.Drawing.Common:

Step 12/14 : RUN ./GitVersionSysDrawingIssue
 ---> Running in 1f86a3a65590
Error:
  An assembly specified in the application dependencies manifest (GitVersionSysDrawingIssue.deps.json) was not found:
    package: 'System.Drawing.Common', version: '4.7.0'
    path: 'runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll'
The command '/bin/sh -c ./GitVersionSysDrawingIssue' returned a non-zero code: 140

If the package were to be restored like above (without the ‘runtime’ in the included assets), then this issue disappears (as there is not any more a dependency on System.Drawing.Common.dll)

Possible Fix

Steps to Reproduce

This behavior can be reproduced with this repository: https://github.com/odalet/GitVersionSysDrawingIssue

  • Clone it on a Linux (or WSL) machine:
git clone https://github.com/odalet/GitVersionSysDrawingIssue.git
cd GitVersionSysDrawingIssue
  • Build/publish:
dotnet publish GitVersionSysDrawingIssue/GitVersionSysDrawingIssue.csproj --configuration Release -o out/
  • Build the docker image
docker build .

The build shoudl fail at step 12 when attempting to run the app in the container.

Then,

  • Edit GitVersionSysDrawingIssue.csproj and remove ‘runtime’ from <IncludeAssets> and repeat publish then docker build.

Context

Trying to run an app that uses GitVersion.MsBuild in a linux Docker.

Your Environment

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
arturciccommented, Apr 7, 2021

@odalet thanks for the information, closing

1reaction
odaletcommented, Feb 1, 2021

Here is my message in a bottle: https://github.com/NuGet/Home/issues/10512

Read more comments on GitHub >

github_iconTop Results From Across the Web

MSBuild Task
MsBuild — is a simple solution if you want to version your assemblies without writing any command line scripts or modifying your build...
Read more >
c# - Embed git commit hash in a .NET dll
The first one, "GetGitHash", loads the git hash into an MSBuild property named BuildHash, it only does this if BuildHash is not already ......
Read more >
GitVersion.MsBuild Auto Increment? : r/dotnet
I had one set up to use svn.exe output dumped into a file I had included in my project as a resource file....
Read more >
GitVersion.MsBuild 5.12.0
Versioning when using Git, solved. GitVersion looks at your git history and works out the Semantic Version of the commit being built.
Read more >
NuGet pack and restore as MSBuild targets
The restore target should not be run in combination with the build target. Restore properties. Additional restore settings may come from MSBuild ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found