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
Difference when building VS solution in VS and msbuild #417
Comments
|
This does look like a bug, thanks for pointing it out. Some further information from a Because the project has metadata That's set here. Setting <CurrentSolutionConfigurationContents>
<SolutionConfiguration xmlns="">
<ProjectConfiguration Project="{DF198BFF-9AD4-45BD-8152-D92259567466}" AbsolutePath="C:\BuildError\A\A.csproj" BuildProjectInSolution="False">Debug|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{0D8A39A6-7DEF-45D4-86E6-41E1FA9BCC8C}" AbsolutePath="C:\BuildError\B\B.csproj" BuildProjectInSolution="True">Debug|AnyCPU</ProjectConfiguration>
</SolutionConfiguration>
</CurrentSolutionConfigurationContents>So I think the culprit is that I don't know yet what the best fix would be. Maybe stop checking that condition for the |
|
Thanks for taking the time to analyze the issue and respond. I´m aware that VS uses msbuild itself behind the curtains. |
|
I don't think there's a straightforward way to do that. VS invokes build for each project individually by logic that it controls. MSBuild attempts to replicate this logic when building a solution by generating There are a few options that I can think of:
|
|
Thanks for sharing your thoughts. It helped me understand a little more how things work under the hood. I think I'm going to re-enable building theses projects (
In the long run, we´re probably going to transition to nuget dependencies, and instead of having a handful solutions with lots of projects, have lots of small solutions that build and publish nuget packages into a internal server, and other projects get the required packages from there. In the mean time, I'll re-enable building the disabled projects in the solution. |
|
Has there been any progress with this issue? I am seeing the same behavior using MSBuild 15.1.1012.6693 We are using build configurations to control the order of what we want built from out of our solution via the command line (i.e. abstractions before implementations) and the project references simply do not get built/included. I've even made sure that the project dependencies are properly configured in the sln file. It was mentioned earlier in the thread that: BuildProjectInSolution="False" possibly was the culprit. |
|
Same issue for me, but solved checking build column of desired project in Configuration Manager. |
|
I have similar issue, I want to set a Solution configuration which does not have a project configuration (I use only as a project filter), but the MSBuild does not recognize and ended up building all the projects. Right now, I am using devenv.exe to build the solution with the desired "filter". |
|
I have the opposite problem: we want to enforce that all ProjectReferences are built as part of the solution, so we have implemented a target that enforces '%(ProjectReferenceWithConfiguration.BuildReference)' == 'true'. MSBuild sets BuildProjectInSolution=false explicitly, which causes BuildReference to be set false and makes this validation logic work as expected. VS IDE leaves this property undefined, the AssignProjectConfiguration target in Microsoft.Common.CurrentVersion.Targets defaults an undefined BuildReference property to true, our validation encounters a false negative, and our build breaks with more esoteric errors from unresolved references in code. We would prefer that MSBuild & VS IDE have matching behavior in that both should set BuildProjectInSolution=false on the ProjectConfiguration when a project is not configured to build in the current solution configuration. Our solution to the problem of "I want project A to build as part of solution 1, then project B to build as part of solution 2" is for project B to use a Reference to A.dll instead of a ProjectReference to A.csproj. We still include project A in solution 2 for easy reference at coding time, but disable its Build in all solution configurations. |
…0401.7 (dotnet#417) - Microsoft.Dotnet.Toolset.Internal - 3.1.202-servicing.20201.7 Dependency coherency updates - Microsoft.NET.Sdk - 3.1.202-servicing.20201.6 (parent: Microsoft.Dotnet.Toolset.Internal) Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
I'm having an issue building some projects. I´ve found differences between building my solutions in VS (it work fine), and building the solutions with msbuild through command line (it fails).
I've managed to make a small sample that illustrates the problem. BuildError.zip
Basically I've got 2 solutions
SolA.slnandSolAandB.sln.SolA.slnonly contains projectA.csprojwhileSolAandB.slncontains bothA.csprojandB.csproj. The projectA.csprojis just a class library, whileB.csprojis a command line project which references projectA.csproj. The subtle peculiarity about this projects, is thatA.csprojis configured to not be built inSolAandB.sln. The reason of this, is that I've got a lot of projects (more than 300, some of which are C# and others are C++ managed and unmanaged), and some projects are included in more than one solution (mainly to allow adding references to the project), but I only want to build the project once.When I build
SolAandB.slnin VS (I'm usingVS2015with update 1, but don't believe that changes anything), I can see that the invocation tocsc.exeforB.csprojis as follows (I've added line breaks between arguments for clarity):Note the
/reference:"F:\Visual Studio 2015\Projects\BuildError\A\bin\Debug\A.dll"which points correctly to the output ofA.csprojfor the selected build configuration. If I had built inRelease, the reference would have correctly pointed to the release build output ofA.csproj.The result of that build depends on having
A.csprojalready built, which I have. You can see a sample build script inBuildSolutions.projwhich first buildsSolA.slnand thenSolAandB.sln.Now if I build
SolAandB.slnthrough the command line, or as a result of buildingBuildSolutions.proj, I can see that the invocation tocsc.exeforB.csprojis as follows:As you can see, beside several apparently subtle differences, the biggest difference is in that the argument
/reference:"F:\Visual Studio 2015\Projects\BuildError\A\bin\Debug\A.dll"is missing, and thus the project fails to build with the errorerror CS0246: The type or namespace name 'A' could not be found (are you missing a using directive or an assembly reference?).How can I build the solution, in a way that when
csc.exeis invoked, it's invoked the same way as when I'm building the solution inside visual studio?The text was updated successfully, but these errors were encountered: