dotnet / dotnet/msbuild

Project built twice - how is this possible?

Open
#5,918 1 comment 0 reactions 1 assignee Claimed by @rainersigwald View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

I hope I'm just doing something embarrassing.

1. git clone CPS --recursive
2. git checkout db101be19c2ce7df573386e0426d164abde427e9
3. msbuild /r /m /bl src\cps.sln /p:DebugType=embedded /p:NuGetInteractive=true /interactive

The binlog from the above build is located at `\\kirillo2\public\Bugs\MSBuild\5918\msbuild5918.binlog`

Open the binlog in the viewer and search for:
`$task CreatePackage project(Microsoft.VisualStudio.ProjectSystem.NuGet.csproj)`

I'm seeing the project Microsoft.VisualStudio.ProjectSystem.NuGet.csproj built twice. The second time CreatePackage runs it clashes because the output is already open by the first instance of the project running.

If everything I believe in is correct the project shouldn't build it's default targets again since it is already being built the first time. How are there two builds of this project? The timeline view confirms that they run concurrently:

![image](https://user-images.githubusercontent.com/679326/100534446-b7fb1000-31c3-11eb-8787-97006d280b51.png)

The actual error I'm getting is:
```
C:\Users\kirill\.nuget\packages\nuget.build.packaging\0.2.2\build\NuGet.Build.Packaging.targets(377,3): The process cannot access the file 'C:\CPS\bin\Debug\packages\nuget\Microsoft.VisualStudio.ProjectSystem.16.8.368-pre-gdb101be19c.nupkg' because it is being used by another process. [C:\CPS\src\Microsoft.VisualStudio.ProjectSystem.NuGet\Microsoft.VisualStudio.ProjectSystem.NuGet.csproj]
```

I see the first time the project is built as a result of building all projects in the .sln. The second time it is built as a reference of Microsoft.VisualStudio.ProjectSystem.Sdk.NuGet.csproj

I'm building using 16.8.2:
```
16.8.2+25e4d540b
16.8.2.56705
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.