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

Project dependency is "not compatible" even when not a reference #2399

Closed
mhutch opened this issue Aug 5, 2017 · 2 comments
Closed

Project dependency is "not compatible" even when not a reference #2399

mhutch opened this issue Aug 5, 2017 · 2 comments
Labels

Comments

@mhutch
Copy link
Member

mhutch commented Aug 5, 2017

The attached example contains two projects, ConsoleApp1, which references net40, and netstandardlib, which references netstandard1.6. They are both in one solution, and ConsoleApp1 is set to depend on netstandardlib but not reference it.

If I build it in VS, the build succeeds.

If I build on commandline, it fails with the following error:

"C:\Users\Mikayla\Projects\netstandardlib\netstandardlib.sln" (default target) (1) ->
"C:\Users\Mikayla\Projects\netstandardlib\ConsoleApp1\ConsoleApp1.csproj.metaproj" (default target) (3) ->
"C:\Users\Mikayla\Projects\netstandardlib\ConsoleApp1\ConsoleApp1.csproj" (default target) (4) ->
"C:\Users\Mikayla\Projects\netstandardlib\netstandardlib\netstandardlib.csproj" (GetTargetFrameworkProperties target) (2:3) ->
(GetTargetFrameworkProperties target) ->
  C:\Program Files\dotnet\sdk\1.1.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.Common.targets(73,5): error : Project 'C:\Users\Mikayla\Projects\netstandardlib\netstandardlib\netstandardlib.csproj' targe ts '.NETStandard,Version=v1.6'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.0'. [C:\Users\Mikayla\Projects\netstandardlib\netstandardlib\netstandardlib.csproj]

VS2017 15.3 Preview 2. Can also repro if I install .NET Core SDK 2.0 preview 2.

netstandardlib.zip

@mhutch
Copy link
Member Author

mhutch commented Aug 5, 2017

I was able to work around this with the following target in the netstandard project

<!-- workaround for https://github.com/Microsoft/msbuild/issues/2399 -->
<Target Name="WorkaroundMSBuildIssue2399" BeforeTargets="GetTargetFrameworkProperties">
  <PropertyGroup>
    <ReferringTargetFramework>$(TargetFramework)</ReferringTargetFramework>
  </PropertyGroup>
</Target>

@rainersigwald
Copy link
Member

We've been tracking this in the Sdk repo, so I'm going to close this as a duplicate of dotnet/sdk#939.

Your workaround is really nice, so I copied it over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants