[Bug] GitVersion.MsBuild should not have 'runtime' listed in the IncludeAssets property
See original GitHub issueDescribe 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
: -
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
- .NET Core 3.1 app
- Visual Studio 2019 v16.8.3
- Windows 10 20H2, Debian 10 WSL (to build the docker image), Docker image: mcr.microsoft.com/dotnet/runtime:3.1
- Repro Repository:< https://github.com/odalet/GitVersionSysDrawingIssue>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
@odalet thanks for the information, closing
Here is my message in a bottle: https://github.com/NuGet/Home/issues/10512