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

Conditional references in csproj files causes error when condition is false #6757

Closed
Pilchie opened this issue Mar 30, 2018 · 4 comments
Closed
Labels
Functionality:Restore Resolution:ByDesign This issue appears to be ByDesign Resolution:Duplicate This issue appears to be a Duplicate of another issue Style:PackageReference Type:DCR Design Change Request

Comments

@Pilchie
Copy link

Pilchie commented Mar 30, 2018

From @reza1024 on July 10, 2017 21:17

I am trying to have a solution with two projects and reference on in the other one only in Debug builds but referencing under conditions causes compile error on Release although it compiles just fine on Debug. It is very easy to reproduce:

1>------ Build started: Project: DebugTools, Configuration: Release Any CPU ------
1>DebugTools -> [Address of Solution]\DebugTools\bin\Release\netstandard1.4\DebugTools.dll
2>------ Build started: Project: MainLibrary, Configuration: Release Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for '[Address of Solution]\DebugTools\DebugTools.csproj'. This can indicate a missing project reference.
2>Done building project "MainLibrary.csproj" -- FAILED.
========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========

Here is the content of the content of the csproj files. I am using VS 15.2 (26430.14)

DebugTools.csproj

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>netstandard1.4</TargetFramework>
	</PropertyGroup>
</Project>

MainLibrary.csproj

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>netstandard1.4</TargetFramework>
	</PropertyGroup>
	<ItemGroup Condition="'$(Configuration)' == 'Debug'">
		<ProjectReference Include="..\DebugTools\DebugTools.csproj" />
	</ItemGroup>
</Project>

Copied from original issue: dotnet/project-system#2583

@Pilchie
Copy link
Author

Pilchie commented Mar 30, 2018

From @srivatsn on July 24, 2017 19:25

If the solution is closed and reopened after changing the configuration to Release (such that the config is Release when the solution is loaded) then it builds fine. It looks like switching configurations doesn't change the set of project references we track for a project.

@Pilchie
Copy link
Author

Pilchie commented Mar 30, 2018

Does this work on command line builds? @nguerrera or @lifengl - where should this be moved?

@Pilchie
Copy link
Author

Pilchie commented Mar 30, 2018

From @nguerrera on March 30, 2018 20:6

This doesn't work on the command line either. I think it's a fundamental issue with the fact that nuget restore shares assets file between configurations. I don't think SDK nor CPS can fix this either. It's more of a nuget issue.

@nkolev92
Copy link
Member

nkolev92 commented Aug 7, 2019

This is a duplicate of #5895.

Project switches such as Configuration,Platform are not supported pivots for PackageReferences.
Only TargetFramework is.

@nkolev92 nkolev92 closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Resolution:ByDesign This issue appears to be ByDesign Resolution:Duplicate This issue appears to be a Duplicate of another issue Style:PackageReference Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

3 participants