I've created a project with two target frameworks: net45 and netstandard1.6
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>TestMonoProject</AssemblyTitle>
<TargetFrameworks>net45;netstandard1.6</TargetFrameworks>
<AssemblyName>TestMonoProject</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PackageReference Include="NETStandard.Library" Version="1.6.1" />
</ItemGroup>
</Project>
I can build the project for both targets
It fails on building for net45 with this error
/usr/share/dotnet/sdk/1.0.0-preview4-004233/Microsoft.Common.CurrentVersion.targets(1107,5): 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. [/home/ravenger/TestMonoProject/TestMonoProject.csproj]
.NET Command Line Tools (1.0.0-preview4-004233)
Product Information:
Version: 1.0.0-preview4-004233
Commit SHA-1 hash: 8cec61c6f7
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/1.0.0-preview4-004233
Mono JIT compiler version 4.6.2 (Stable 4.6.2.7/08fd525 Mon Nov 21 12:08:40 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
It is possible to build net45 projects with Mono in preview2. But there is a problem with xunit tests. But in preview4 everything are broken.
@srivatsn @nguerrera @dsplaisted This seems like an SDK problem.
It think it the same as https://github.com/dotnet/sdk/issues/335
The SDK people also pointed a shortcoming in xbuild itself when running under .NET Core.
I have recently read that the .NET Core version of MSBuild is only meant to build .NET Core projects. If this is true, we will need a variant of the CLI that uses the Mono flavour of MSBuild or an option to specify the MSBuild path (preferably an ENV VAR). I do not only target .NET Core but also target Mono when developing on my machines (which all run Linux).
Dnx and Dotnet CLI preview 2 supports Mono out-of-the box. I think this version of CLI should support it as well
As @livarcocc mentioned, the right place for this issue is the SDK repo and potentially the MSBuild repo. The dotnet/sdk#335 issue already tracks this and @borgdylan mentioned on that issue that he opened another one on MSBuild. With all of that, I will close this issue and let the discussion continue on the SDK issue.
if you feel this is an error, please reopen. Thanks!
Most helpful comment
Dnx and Dotnet CLI preview 2 supports Mono out-of-the box. I think this version of CLI should support it as well