Nsubstitute: Building on Mac/Linux with net45/net46 targets

Created on 26 Oct 2017  Â·  4Comments  Â·  Source: nsubstitute/NSubstitute

dotnet build on Mac:

error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. 

I have dotnet CLI 2.0.0 and Mono 5.4.1.4 installed:

~/dev/git/nsubstitute  [master]✗ % dotnet --version
2.0.0
~/dev/git/nsubstitute  [master]✗ % mono --version
Mono JIT compiler version 5.4.1.4 (2017-06/c6605763a36 Fri Oct 13 15:34:43 EDT 2017)
...

According to this comment referencing Microsoft.TargetingPack.NETFramework.v4.6.1 might help?

<PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.6.1" Version="1.0.1" ExcludeAssets="All" PrivateAssets="All" /> 

Using dotnet test -f netcoreapp1.1 succeed (with a warning):

~/dev/git/nsubstitute  [master]✗ % dotnet test -f netcoreapp1.1
Build started, please wait...
/usr/local/share/dotnet/sdk/2.0.0/Sdks/Microsoft.NET.Sdk/build/Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file '/Users/dtchepak/dev/git/nsubstitute/src/NSubstitute/obj/project.assets.json' doesn't have a target for '.NETCoreApp,Version=v1.1'. Ensure that restore has run and that you have included 'netcoreapp1.1' in the TargetFrameworks for your project. [/Users/dtchepak/dev/git/nsubstitute/src/NSubstitute/NSubstitute.csproj]
Build started, please wait...
Build completed.
...
Total tests: 465. Passed: 443. Failed: 0. Skipped: 8.
Test Run Successful.
Test execution time: 2.8702 Seconds
build good first issue help wanted

Most helpful comment

Link to official SDK issue regarding this issue. You can build single csproj items specifying the target framework: dotnet build NSubstitute.csproj -f netstandard1.3

All 4 comments

@alexandrnikitin Not sure if you can shed any light on this?

Link to official SDK issue regarding this issue. You can build single csproj items specifying the target framework: dotnet build NSubstitute.csproj -f netstandard1.3

More links:

Got a little further using:

FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/4.7-api dotnet build

Now getting:

error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

It is still in preview but Reference Assemblies probably is the way to go. I'd be happy to work on it.

Edit: I was too eager and already worked on it. 😅. Let me know if it works for you.

Was this page helpful?
0 / 5 - 0 ratings