-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Project dependency specified in .sln file, causes build to fail, on Unix #1957
Comments
This old blog should be relevant: https://blogs.msdn.microsoft.com/msbuild/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe/ |
Team Triage: |
I was mistaken. It doesn't look like a regression. I will investigate why this is happening on mono/mac though. |
Given a .sln with: Projects A, B and C. A has a ProjectReference to B B depends on C, specified in the .sln file ``` Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibB", "LibB\LibB.csproj", "{34ED4F6B-145E-467E-AFFB-48B3237878D3}" ProjectSection(ProjectDependencies) = postProject {9C743F94-9DA8-422B-8FB8-DEB139216381} = {9C743F94-9DA8-422B-8FB8-DEB139216381} EndProjectSection EndProject ``` Building this with msbuild: ``` "/Users/ankit/Projects/SlnProjectDepsBug/SlnProjectDepsBug.sln" (default target) (1) -> "/Users/ankit/Projects/SlnProjectDepsBug/LibB/LibB.csproj.metaproj" (default target) (5) -> /Users/ankit/Projects/SlnProjectDepsBug/LibB/LibB.csproj.metaproj : error MSB4025: The project file could not be loaded. Could not find file "/Users/ankit/Projects/SlnProjectDepsBug/LibB/LibB.csproj.metaproj". ``` The solution project generator creates a Project and ProjectInstance for `LibB.csproj.metaproj`, and a `BuildRequestConfiguration` gets added to `BuilderManager._configCache` from `LoadSolutionIntoConfiguration`. But it has a property: CurrentSolutionConfigurationContents=<SolutionConfiguration> <ProjectConfiguration Project="{2A45AC7E-98A0-4AA8-84F0-7C02A7469313}" AbsolutePath="/Users/ankit/Projects/SlnProjectDepsBug/SlnProjectDepsBug\SlnProjectDepsBug.csproj" BuildProjectInSolution="True">Debug|x86</ProjectConfiguration> <ProjectConfiguration Project="{9C743F94-9DA8-422B-8FB8-DEB139216381}" AbsolutePath="/Users/ankit/Projects/SlnProjectDepsBug/LibC\LibC.csproj" BuildProjectInSolution="True">Debug|AnyCPU</ProjectConfiguration> <ProjectConfiguration Project="{34ED4F6B-145E-467E-AFFB-48B3237878D3}" AbsolutePath="/Users/ankit/Projects/SlnProjectDepsBug/LibB\LibB.csproj" BuildProjectInSolution="True">Debug|AnyCPU<ProjectDependency Project="{9C743F94-9DA8-422B-8FB8-DEB139216381}" /></ProjectConfiguration> </SolutionConfiguration> .. with `LibB\LibB.csproj`. And at a later point the instance gets looked up from `BuildRequestEngine.IssueBuildRequests`, and at this point the build request has the same property but with fixed paths, which causes the `GetMatchingConfiguration` to fail trying to match the property. IOW, it fails to find the `ProjectInstance` for `LibB.csproj.metaproj` and so tries to load the project file instead, which doesn't exist on disk! `ProjectInSolution.RelativePath` should fix up the project path being read from the sln file. `ParentSolution.SolutionFileDirectory` is built correctly, and it's setter is used only by tests. So `ProjectInSolution.AbsolutePath` doesn't need to be updated. FIXME: Added a test project but it is not integrated in the build. It should probably be added in SolutionProjectGenerator_Tests. (dotnet#1957)
I'll open a PR for this in a few days. This is the patch that I am using: mono@4a3d1b1 |
Likewise experiencing this issue on Mac - project solution from Visual Studio 2017, errors when built on VS Code. Solution excerpt:
Generates error on build:
VS Code, Version 1.15.1 (1.15.1) 41abd21 .Net Core 2.0 project specifying dependency to .Net Standard 2.0 library. Removing the post project dependency from the .sln file builds without errors. |
I have the same issue on Linux when the project dependency is specified in the
But it works perfectly on Visual Studio 2017 and Visual Studio for Mac. Removing the dependency in the I'm using .NET Core 2.0 SDK. |
while |
My issue is slightly different, but I found a solution that might help you out. In my Solution.sln, I have 3 csproj :
When I do a "dotnet restore", everything is fine, but doing a "dotnet publish ./MySolution.sln -c Release -o ./obj/Docker/publish", it gave me errors about .csproj.metaproj missing. But removing C's dependency on A seems to have fixed the problem. Not saying this is the best solution (or even feasible in some situation), but I managed to fix it this way on my end. edit : Just to mention, I'm running on Core 2.0 SDK and Ubuntu 16.04 |
To add to my previous fix : It worked for some sln, but not all of them (I don't know why it actually worked, maybe simply touching the csproj made a difference?) Anyway, the fix is actually what @jasonsturges mentionned : the proper solution to remove the postProject part of your .sln file (anything between ProjectSection and EndProjectSection, including those tags) |
When deps are not specified in a solution file they're all published with a Debug configuration for some reason. When deps are specified than each and every dep requires framework and rid specified in csproj. So both ways are not working properly |
My .net core 2.0 console application runs properly in Windows OS. But I m having problem running it on RHEL7. In my .sln file, I have 6-7 projects (.Net Stansard Library 2.0). Some projects depends on some other. But my solution file does not contain any word like postProject. When I run following command, it gives no error and command prompt comes back without doing anything. Also it gives no error or nothing. My application uses SQL connection, Reflection, Third Party dlls( developed in c++), socket connection etc. I also tried running a demo application with command line arguments, SQL connection. It works fine in RHEL7. What could be the problem? If you have any idea regarding this please share. |
yes deleting /obj during the build fixed it for me |
I can confirm that the workaround is to manually edit the .sln file and change the paths to use slashes instead of backslashes. The solution will then correctly restore on Windows and Linux. The changes I just made to make Froto.sln restore on Travis CI: This is a bug. We should have to make this change to make it work on Unix. |
Same here, if [ "$(uname)" == "Linux" ]; then
echo "Unfucking xxx.sln for ${__BuildOS}"
sed -i 's#\\#/#g' xxx.sln
fi |
Same with .net core sdk 2.1.3 |
Fixes dotnet#2022, fixes dotnet#1957. Ported the code change only from mono@86adc96.
Fixes dotnet#2022, fixes dotnet#1957. Ported the code change only from mono@86adc96.
Hey @rainersigwald I'm experiencing this issue with dotnet Core, when will your commit be made into a release to resolve the issue? The suggested |
@Chaosca It should be in 2.1-preview2; unfortunately it didn't make -preview1. |
This is happening again in my solution first created on mac, then migrated to VS2017. Now when building the solution on macosx again I get the error:
|
@halcwb Editing the slashes back to |
I have a
.sln
with:Projects A, B and C.
A has a
ProjectReference
to BB depends on C, specified in the
.sln
fileBuilding this with msbuild:
From what I able to gather, the
SolutionProjectGenerator
creates aProjectInstance
forLibB.csproj.metaproj
. WhenRequestBuilder
starts to build the.sln.metaproj
and wants to buildLibB.csproj.metaproj
, it doesn't seem to have access to the earlierProjectInstance
and tries to create a new one, which tries to access the file, but since that was just in-memory, it fails.If you run it with
MSBuildEmitSolution=1
then theLibB.csproj.metaproj
is written to disk and the build succeeds.Also, there is a bug due to which if you use
MSBUILDEMITSOLUTION=1
(note the case!), the.sln.metaproj.tmp
is written to disk before the.csproj.metaproj
has been added to it, so you won't see it there. I'll add open a PR for that.The text was updated successfully, but these errors were encountered: