Build/Test Issues

csproj targetFrameworks netstandard1.3;net461 gives error

Started by RichardAnderssen on 6,625 views

Hi!

After changing a csproj-file to new format:
---
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net461</TargetFrameworks>
<PackageId>Someproject</PackageId>
</PropertyGroup>
<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Someproject.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>

---
my Visual Studio 2017 v.15.6.4 compiles and runs just fine,
but NCrunch gives build error and reports:
C:\Program Files\dotnet\sdk\2.1.103\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets: Assets file 'C:\Users\Someuser\AppData\Local\NCrunch\7312\8\Someproject\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.6.1'. Ensure that restore has run and that you have included 'net461' in the TargetFrameworks for your project.


How can I resolve this? I'm using NCrunch 3.12.0.15

Regards, Richard
Hi Richard,

Thanks for posting.

This looks like a project.assets.json refresh issue. This file is controlled by Visual Studio and sometimes when you make structural changes to your project, weird things can happen with it.

Try the following:
1. Close Visual Studio
2. Go to your solution directory, delete ALL bin and obj directories under the projects involved
3. Re-open Visual Studio
4. Re-build the solution in VS
5. Enable NCrunch
Hi again,

and thanks for the swift reply.

The problem still persists, even after trying the steps you mentioned above.

There is also now an extra line reported in NCrunch, which is an extra project failing to build, reported for netstandard 1.3:

C:\Program Files\dotnet\sdk\2.1.103\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets: Assets file 'C:\Users\Someuser\AppData\Local\NCrunch\26492\2\Someproject\obj\project.assets.json' doesn't have a target for '.NETStandard,Version=v1.3'. Ensure that restore has run and that you have included 'netstandard1.3' in the TargetFrameworks for your project.

Are you able to reproduce this problem in a fresh sample project?
Yeah, I reproduced the error in a small solution, with one console-project having net461, referencing a simple class library project which I tried with the different project setup-possibilities as described below.
Also got fixtures for ncrunch, in a class library with net461, referencing the aforementioned simple class library.

Gives error:

<TargetFramework>netstandard1.3</TargetFramework>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard1.3;net461</TargetFrameworks>

Runs OK:

<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net461</TargetFramework>

I also sent in a zip with the reproduced VS solution through the support online contact form.

Edited

A thing we noticed; In the error, seems NCrunch is reporting:
C:\Program Files\dotnet\sdk\2.1.103\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets

This should indicate that NCrunch uses SDK 2.1.103.

However, global.json in solution folder, has this:
{
"sdk": {
"version": "2.0.3"
}
}

Maybe a longshot in the dark, but is NCrunch not adhering to global.json? And can I make it?

Thanks for the sample solution! Interestingly, this sample seems to work correctly in my own environment. So there must be an environmental component to this somewhere.

If global.json is needed in your environment for the projects to build, it's possible that this file isn't being included in the NCrunch workspace. If this is indeed the case, you may be able to solve the problem by adding it to the 'Additional files to include' setting for your solution.

I think that something in the MS tool stack is going wrong somehow here. It's possible the problem is tied to the versions of the .NET Core/Standard SDK that are installed on your machine. The newer SDKs seem to have a large number of moving parts making troubleshooting them very difficult. Let me know if the global.json inclusion doesn't solve the issue, and we'll try a few other things.
Adding the 'global.json' to "Additional files to include" for both net461 and netstandard1.3 in NCrunch did the trick - NCrunch compiles and runs flawlessly now!

Thanks for the help!
Might be good to know for others who has a mix of SDK's installed, I believe.

Post a reply

Log in to reply.