-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
dotnet build fails on solution with .net framework project while msbuild succeeds #5230
Comments
@joperezr could you help with this? |
@krishnan-unni thanks for logging this. Can you repro locally on a clean environment if you try to do dotnet build? Sounds like the issue in your case is something related with Restore, since the first time you build after clearing out obj seems like it is failing as well but the second time works out fine. If you could, clean bin and obj directory and then perform a build like: |
Closing due to lack of response. |
I am still reproducing this, fwiw, in the scenario of a solution with a mix of v2015 and v2015 (sdk-style) csproj formats, where the targetframwork is net472 on the sdk csprojs and v4.7.2 on the v2015 csprojs, with one of the final projects requiring a nuget package that has netstandard2.0;net472 the restore solution will bring in the nuget package dependency correctly, and then a build in VS will remove it. However, from the console, doing an msbuild -t:restore, then an msbuild -t:build on the same machine it is successful. I am on the latest VS2019, 16.8.4, with MSBuild 16.8.3.61104, nuget 5.81. Ultimately I am thinking that perhaps I have an unsupported scenario. MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet That is in an sdk project that is a dependency of two later projects, and just inside the root node: As I did not add this myself, I am a bit confused about it and have not found adequate information to know what knobs it exposes, but I can't help but think that knowing the secrets to it means I can get builds in visual studio to not stomp out nuget restore operations. Either way, certain early projects, if I roll them back to the v2015 csproj format, and clear all the obj and bin folders, will still get the RuntimeIdentifier issue described above. I was not able to find any workaround on the web that actually worked, and again, I wouldn't expect to need this RuntimeIdentifier element in a v2015 csproj in the first place. |
Started getting this issue after migrating from The fix, as described in this comment, is to either:
Both of these solutions worked in my case. Make sure to clean out your |
When I try to build a solution that contains a .Net Framework project which consumes a nuget package which is multi targeted, it fails to build with "dotnet build" command while it builds fine in visual studio or with command msbuild
I have a solution with 4 projects :
When I build the solution in Visual studio 2019 or with CLI using msbuild.exe command, the solution builds fine; ProjectB's nuget package generated and client apps build fine and I am able to execute them as well.
When I build the same solution using "dotnet build" (it is what is used in the CI pipeline) all the projects executes and build fine except ClientB which is the .net framework project. The error is:
"Restored ClientB.csproj (in 251 ms).
3 of 4 projects are up-to-date for restore.
The type or namespace name '{ProjectA's namespace}' could not be found (are you missing a using directive or an assembly reference?"
This points out that the build is not compiling ClientB project properly or not restoring the nuget package for it properly, making it miss those dependent namespaces.
Is this expected or a shortcoming/bug with "dotnet build" building .Net Framework projects in solutions?
Additional information:
When ever I build the solution using "dotnet build" and it fails, then I try to build the same in Visual Studio the following error is thrown for ClientB project:
" Error: Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore. (1, 1)"
It doesn't make any difference even if I add the RID in csproj file. Then when I go and delete the 'obj' folder for that project and builds, I get the same error in Visual Studio as in dotnet cli - References not found.
When I close my Visual Studio and open the solution again and then do a build - All good. Successful build.
This points to some issue with the way dotnet restores the nuget and treats the projects while building.
The text was updated successfully, but these errors were encountered: