Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancy between build.cmd and IDE build #5999

Open
KirillOsenkov opened this issue Jan 2, 2021 · 5 comments
Open

Discrepancy between build.cmd and IDE build #5999

KirillOsenkov opened this issue Jan 2, 2021 · 5 comments
Assignees
Labels
Area: Our Own Build Problems affecting the build or build infrastructure of the MSBuild repo itself. bug triaged

Comments

@KirillOsenkov
Copy link
Member

When I type build.cmd to build the MSBuild repo on Windows it ends up with this command line:

/m /nologo /clp:Summary /v:minimal /nr:True /p:ContinuousIntegrationBuild=False /warnaserror /p:TreatWarningsAsErrors=true "C:\Users\kirill\.nuget\packages\microsoft.dotnet.arcade.sdk\1.0.0-beta.20580.3\tools\Build.proj" "/bl:C:\msbuild\artifacts\log\Debug\Build.binlog" "/p:Configuration=Debug" "/p:RepoRoot=C:\msbuild" "/p:Restore=True" "/p:DeployDeps=False" "/p:Build=True" "/p:Rebuild=False" "/p:Deploy=False" "/p:Test=False" "/p:Pack=False" "/p:IntegrationTest=False" "/p:PerformanceTest=False" "/p:Sign=False" "/p:Publish=False""

When I open MSBuild.Dev.sln in Visual Studio, some of these properties are not set, so the in-IDE behavior is slightly different. Specifically, projects always rebuild even if nothing has changed: this file: C:\msbuild\artifacts\obj\Microsoft.Build.Framework\Debug\net472\Microsoft.Build.Framework.AssemblyInfo.cs has an extra attribute ([assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/microsoft/msbuild")]) compared to the command-line build. It gets added because of a different default (GenerateRepositoryUrlAttribute = true in the IDE builds).

I think the default behavior for build.cmd should match as closely as possible the defaults picked by the build if you just do msbuild /r /m /bl with no extra properties. This way opening the solution in the IDE will result in the same builds instead of flip-flopping and competing with the command-line build and breaking incrementality.

@KirillOsenkov KirillOsenkov added bug needs-triage Have yet to determine what bucket this goes in. Area: Our Own Build Problems affecting the build or build infrastructure of the MSBuild repo itself. labels Jan 2, 2021
@KirillOsenkov KirillOsenkov self-assigned this Jan 3, 2021
@KirillOsenkov
Copy link
Member Author

Actually I think this is because the difference is resolved SDK (3.1 in command-line case vs. 5.0 in the IDE case). 5.0 added a new attribute, so depending on which SDK you're using to build you'll get a different set of generated attributes in the AssemblyInfo.cs.

I think we can close this one then (it is expected that if you use different SDKs you might get slight discrepancies between builds like this).

@KirillOsenkov
Copy link
Member Author

KirillOsenkov commented Jan 3, 2021

Turns out I had to set these environment variables to replicate the behavior of resolving 3.1.100:

PATH=C:\msbuild\.dotnet;%PATH%
DOTNET_INSTALL_DIR=C:\msbuild\.dotnet
DOTNET_MULTILEVEL_LOOKUP=0

Is there a file equivalent of setting these (such as an .rsp file?) so that the behavior we get in VS is identical to the build.cmd behavior?

The workaround is to set the two environment variables and open VS from that prompt to inherit that environment. Otherwise you'll keep getting little discrepancies as a result of vanilla VS choosing a different SDK.

@KirillOsenkov KirillOsenkov reopened this Jan 3, 2021
@KirillOsenkov
Copy link
Member Author

I've also filed dotnet/sdk#15149 because I literally spent whole day on this issue.

@rainersigwald
Copy link
Member

I think the ideal solution would be dotnet/sdk#8254.

FYI @KathleenDollard -- here's another global.json-adjacent thing that would be made worse by ignoring it.

@benvillalobos benvillalobos removed the needs-triage Have yet to determine what bucket this goes in. label Jun 9, 2021
@KirillOsenkov
Copy link
Member Author

Sigh, I keep wasting time on this, doing the same investigation over and over. After a few months I forget about this and start the whole investigation from scratch, and always come back to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Our Own Build Problems affecting the build or build infrastructure of the MSBuild repo itself. bug triaged
Projects
None yet
Development

No branches or pull requests

4 participants