dotnet / dotnet/msbuild

msbuild doesn't copy c++ referenced content file into c# output dir

Open
#2,823 6 comments 2 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

### Steps to reproduce

one solution including:
one c# project
one c++ project
x64 solution configuration, including c++ as x64, and c# as Any Cpu (or x64 - doesn't matter)
in the csproj file add:
```xml

false
Content
Always

```

Command line
```
msbuild solution.sln /m /t:rebuild /p:configuration=debug /p:platform=x64
```
### Expected behavior
the native dll should be copied over to the output of the c# project

### Actual behavior
the native dll is not copied over to the output of the c# project

### Environment data
`msbuild /version` output:
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

15.3.409.57025

OS info:

Windows 10, Visual Studio 2017

More info:
In visual studio - this works fine.
I have reduced my debugging to `Microsoft.Common.CurrentVersion.targets`, to where `QUIRKING FOR DEV10` exists. Seems like adding `GetTargetPath` to the msbuild task that has the following comment -
`Build referenced projects when building from the command line.` - makes it work.
Also, setting DesignTimeBuild to true - solves this, but dependencies are not built in the correct order - so in the end this is not a solution.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the stated C# and C++ projects using the msbuild solution.sln /m /t:rebuild command and x64 configuration. Start in Microsoft.Common.CurrentVersion.targets around the “Build referenced projects when building from the command line” task and the GetTargetPath behavior. Done means the native DLL is copied to the C# output directory without breaking dependency build order.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.