dotnet / dotnet/msbuild

Inconsistent behavior in building project references between Visual Studio and dotnet cli build

Open
#5,599 10 comments 1 reaction 0 assignees View on GitHub
bug triaged under-investigation
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

MSBuild offers the possiblity to pass additional properties for build project references. However, that only works well with dotnet cli, not with Visual Studio. I have created a sample repository that demonstrates the problem. The visual studio build fails, because the zip of the reference project is not being generated. With the dotnet cli the build works as expected.

The demo repo is here:
https://github.com/TFTomSun/IncosistentBuildBehavior

```xml
...

true
false
TargetFramework=net48
****
PublishZipFilePath=$(MSBuildProjectDirectory)\Resources\%(ReferenceName).zip

...
```

Are there any plans to align the Visual Studio build with the msbuild / dotnet cli behavior? I had those issues already several times and it makes it really difficult to cover all quirks of the msbuild behavior in different contexts at the moment.

Actually I don't know how to workaround the issue. Of course I could start a MSBuild Task on my own, but then I would actually build the dependent project twice. That's probably also the reason, why building the project dependencies in Visual Studio via MSBuild is disabled here:
Excerpt from Microsoft.Common.CurrentVersion.targets line 1807

```xml



```
The 'BuildingInsideVisualStudio' in the condition check causes the different behavior.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked demo repository and the Microsoft.Common.CurrentVersion.targets condition around line 1807. Compare the Visual Studio and dotnet CLI builds, focusing on whether AdditionalProperties reaches the referenced project. Done means the Visual Studio build generates the reference project's zip as the CLI build does, without building the dependency twice.

Written by the indexing model from the issue text.

Assessment

Tech stack
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.