dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.72k stars 1.07k forks source link

Build for desktop framework on non-windows platforms #335

Closed dasMulli closed 4 years ago

dasMulli commented 8 years ago

The dotnet CLI allowed to build net* targets on mac and linux using the reference assemblies installed with mono. It seems this is not supported by the targets in Microsoft.NET.Sdk. For fun, I also tried referencing the targeting pack NuGets which also didn't work.

Is there a plan for bringing back support for building net* projects on linux/mac? Or should it already work?

TheAngryByrd commented 6 years ago

@jskeet I'm not really sure as to why but github doesn't seem to be showing all comments on this issue.

As a summary: if you're looking to build on macos/linux there's a few options.

Setting an environment variable: https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-1.0.1#using-net-framework-as-targets-framework-the-osxunix-build-fails

So put export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5/ in your build.sh.

Setting properties in the proj file: https://github.com/dotnet/sdk/issues/335#issuecomment-368669050

Using myget feed: https://github.com/dotnet/sdk/issues/335#issuecomment-271186591

jskeet commented 6 years ago

@TheAngryByrd: That's good to know, thanks. Does that FrameworkPathOverride only apply to net* TFMs? My projects target netstandard and net45, so I can see myself needing to do something in the build file if it isn't smart enough already.

I'd really like to be able to do this without a full Mono installation though - as I mentioned, it feels like it should be feasible to refer to a directory which already has the reference assemblies present. (Ideally, it shouldn't even need that - MSBuild could fetch a package with them if it didn't have them locally, and use the packaged version.)

As the .NET Core SDK is increasingly mature, this is the sort of issue I'd really appreciate being addressed in a simpler way :)

cc @KathleenDollard who may be interested...

TheAngryByrd commented 6 years ago

@jskeet I haven't tried without mono installed but if it did work, the myget feed solution of would be my guess as the one that would https://github.com/dotnet/sdk/issues/335#issuecomment-271186591

jskeet commented 6 years ago

@TheAngryByrd: Ah, missed that one. Thanks - will give it a try, although obviously a long term solution shouldn't need myget either...

akoeplinger commented 6 years ago

Hey, please don't use lib/mono/4.5/ for FrameworkPathOverride. Despite the name it contains our latest profile which means you'll get access to newer APIs that can make your code incompatible with .NET Framework.

Use the -api folders instead, i.e. lib/mono/4.5-api/, lib/mono/4.6.1-api/, lib/mono/4.7-api/ etc.

Essentially use https://github.com/dotnet/sdk/issues/335#issuecomment-368669050.

akoeplinger commented 6 years ago

And yes I agree needing Mono for this is a bit backwards since the reference assemblies could just come from NuGet.

TheAngryByrd commented 6 years ago

Oh that's really good to know. Thanks for pointing that out.

jskeet commented 6 years ago

Putting the various comments together, this project file works for me building a trivial project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netstandard1.0;net45;netstandard2.0</TargetFrameworks>
    <!-- Add the myget feed, without altering any other configurations. -->
    <RestoreAdditionalProjectSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreAdditionalProjectSources>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TargetFramework)'== 'net45'">
    <!-- Make .NET 4.5 reference assemblies available even on Linux -->
    <FrameworkPathOverride>$(NuGetPackageRoot)microsoft.targetingpack.netframework.v4.5/1.0.1/lib/net45/</FrameworkPathOverride>
  </PropertyGroup>

  <ItemGroup Condition="'$(TargetFramework)'== 'net45'">
      <!-- Make sure the reference assemblies are available -->
      <PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.5"
                        Version="1.0.1" ExcludeAssets="All" PrivateAssets="All" />
      <!-- The DLL case has changed between 4.5 and 4.6; this avoids a warning. -->
      <Reference Include="System.XML" />
  </ItemGroup>

</Project>

It's still unsupported, of course... I wonder who we need to lobby to make this an officially-supported scenario...

(This is all particularly relevant now that we're at the stage where full signing works or will imminently work on Linux.)

nguerrera commented 6 years ago

Lobby @terrajobst and team to make the targeting pack nupkgs official. We can do the rest.

ghost commented 6 years ago

@terrajobst and team, please make the targeting pack nupkgs official (including .NET Framework 2.0+ and kinds of PCL profiles). @nguerrera and team can do the rest. 🙏

lucasmeijer commented 6 years ago

@terrajobst we at unity would also greatly appreciate having official .net framework targetting pack nugets.

dasMulli commented 6 years ago

Targeting pack MSIs are a pain anyhow. They just drop a folder into a well-known location which msbuild then uses. And it is prone to breaking if users changes their program files path (https://github.com/dotnet/cli/issues/6770#issuecomment-333873454).

Fast forward 8 years after the net40 it feels like NuGet should have always been the delivery mechanism for targeting packs 😄 (yes I know it wasn't an option back then)

jnm2 commented 6 years ago

🎉 https://github.com/dotnet/designs/pull/33/files?short_path=4c085c4#diff-4c085c464d992b00504305a5996f804c

jnm2 commented 6 years ago

Non-Goals

  • Support pre-.NET Framework 4.5 targeting packs

😭

kekekeks commented 6 years ago

It would be nice to have targeting packs for Xamarin platforms as well. Just to be able to compile xplat libraries for these platforms using .NET Core SDK.

livarcocc commented 6 years ago

@dsplaisted can you give us an ETA for this?

AArnott commented 6 years ago

I'd also like to submit a request for portable-* TxM's. Yes, some packages (still) have popularity in PCL profiles. I can build them on Windows in .NET SDK projects using @onovotny's MSBuildSdkExtras, so whether with or without that package I don't care, but I'd like to be able to build those packages on linux too.

eerhardt commented 6 years ago

@AArnott - I think you may get more visibility requesting PCL support on https://github.com/dotnet/designs/pull/33/. I'm not sure if you are aware of that document, but that's the design/requirements doc that will enable fixing this current issue (#335).

prochnowc commented 6 years ago

Did anyone get the workaround applied by the F# team to work onAppVeyor linux builds? dotnet build cannot find framework assemblies even when adjusting FrameworkPathOverride.

/usr/share/dotnet/sdk/2.1.300/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

dsyme commented 6 years ago

@prochnowc Do you have mono installed on the AppVeyor machine?

prochnowc commented 6 years ago

@dsyme Yes AppVeyor for Linux has Mono 5.12 pre-installed https://www.appveyor.com/docs/getting-started-with-appveyor-for-linux/#pre-installed-software

prochnowc commented 6 years ago

I've setup clean VM with same Ubuntu, Monto and .NET Core SDK. When expirementing i noticed that by default the AssemblySearchPaths is set to {CandidateAssemblyFiles};{HintPathFromItem};{TargetFrameworkDirectory};{RawFileName}.

I changed the value provided by the F# team from <AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths> to <AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride);$(FrameworkPathOverride)/Facades;{CandidateAssemblyFiles};{HintPathFromItem};{RawFileName}</AssemblySearchPaths>

Now it seems it can compile (at least in my own Ubuntu VM).

Miggleness commented 6 years ago

What's the guidance for targeting net framework 4.5 and up on non-Windows platform? Using targeting packs did work for me, but the targeting pack packages are still non-searchable in Nuget despite being around for 2-3 years.

dasMulli commented 6 years ago

Those packages aren’t really meant for public consumption. Personally I recommend using mono to build on *nix

jskeet commented 6 years ago

@dasMulli: That's really not a great solution in terms of having to install multiple things in CI servers etc. If I'm just building against reference assemblies, there's no logical need for a full-blown Mono installation as well as the .NET Core SDK.

https://github.com/dotnet/designs/pull/33 indicates the way forward, which I think will be much, much more pleasant. (I now see you've been active in that PR anyway.)

dasMulli commented 6 years ago

@jskeet: those packages are missing a few bits, I think someone here ran into it but not sure where it is logged. If the build worksusing the package then great, but i wouldn’t recommend it as a general purpose solution. Only mono‘s msbuild has the ifdef‘d logic to process mono‘s ref assembly structure. Yeah I’m the one who logged this issue so been active ever since in this topic ^^

jskeet commented 6 years ago

I'd go in the other direction - if Mono works for the moment, that's great, but I don't want that to be the long term solution :)

Miggleness commented 6 years ago

My objective,and likely most cases of building on non-windows platform, would just like build to work. Not necessarily to deploy the assembly for .net framework. Good to see the first option is to go with reference targeting packs.

wadewegner commented 6 years ago

I was able to target both netstandard2.0 and net452 by using FrameworkPathOverride and including microsoft.targetingpack.netframework.v4.5.2 from myget. Appears to be working quite well for me on MacOS.

https://gist.github.com/wadewegner/a66af31149d279757357b05deb6c032c

alastairs commented 6 years ago

I tried out a slightly modified form of @wadewegner's Gist for net471, but I found that I had to include a line <Reference Include="netstandard"> in order for build to succeed (the application depends on libraries which only target netstandard2.0). However, when I came to run the application within its Docker container, it crashed with the following exception:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. File not found. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. File not found.

I've probably missed something, but I can't really tell what from this output. Do I need to, e.g., copy the Targeting Pack assemblies to the publish folder, or make my libraries target net471 too? System.Runtime doesn't appear in the publish folder right now.

gaviriar commented 6 years ago

Hi there, I also updated my project like the example by @dasMulli but for net472.

My build throws a couple of warnings and the error at the end that mscorlib.dll could not be found:

/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Image is too small. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Data". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Drawing". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Xml". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Core". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Runtime.Serialization". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Xml.Linq". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Numerics". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.IO.Compression.FileSystem". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Configuration". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.IO.Compression". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.ServiceModel". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Transactions". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/gaviriar/net_compile/net_compile.csproj]
CSC : error CS0006: Metadata file '/mscorlib.dll' could not be found [/home/gaviriar/net_compile/net_compile.csproj]

Upon some investigation, and searching through the .nuget/packages:

find /home/gaviriar/.nuget/ -name "*mscorlib.dll"
/home/gaviriar/.nuget/packages/microsoft.netcore.app/2.0.0/ref/netcoreapp2.0/mscorlib.dll
/home/gaviriar/.nuget/packages/microsoft.netcore.app/2.1.3/ref/netcoreapp2.1/mscorlib.dll
/home/gaviriar/.nuget/packages/microsoft.targetingpack.netframework.v4.7.1/1.0.0/lib/net471/mscorlib.dll
/home/gaviriar/.nuget/packages/netstandard.library/2.0.2/build/netstandard2.0/ref/mscorlib.dll
/home/gaviriar/.nuget/packages/netstandard.library/2.0.0/build/netstandard2.0/ref/mscorlib.dll
/home/gaviriar/.nuget/packages/microsoft.targetingpack.netframework.v4.5.1/1.0.1/lib/net451/mscorlib.dll
/home/gaviriar/.nuget/packages/microsoft.targetingpack.netframework.v4.6.1/1.0.1/lib/net461/mscorlib.dll
/home/gaviriar/.nuget/packages/microsoft.targetingpack.netframework.v4.5.2/1.0.1/lib/net452/mscorlib.dll
/home/gaviriar/.nuget/packages/runtime.win-x64.microsoft.netcore.app/2.0.0/runtimes/win-x64/lib/netcoreapp2.0/mscorlib.dll
/home/gaviriar/.nuget/packages/runtime.win-x64.microsoft.netcore.app/2.1.0/runtimes/win-x64/lib/netcoreapp2.1/mscorlib.dll
/home/gaviriar/.nuget/packages/runtime.win-x64.microsoft.netcore.app/2.1.3/runtimes/win-x64/lib/netcoreapp2.1/mscorlib.dll
/home/gaviriar/.nuget/packages/runtime.linux-x64.microsoft.netcore.app/2.0.0/runtimes/linux-x64/lib/netcoreapp2.0/mscorlib.dll
/home/gaviriar/.nuget/packages/runtime.linux-x64.microsoft.netcore.app/2.1.0/runtimes/linux-x64/lib/netcoreapp2.1/mscorlib.dll
/home/gaviriar/.nuget/packages/runtime.linux-x64.microsoft.netcore.app/2.1.3/runtimes/linux-x64/lib/netcoreapp2.1/mscorlib.dll

It seems like the mscorlib.dll file is missing in the net472 targeting packs. Unfortunately, I need to target net472 and cannot use anything lower. How should I go about requesting an update of this package (if even possible)?

dasMulli commented 6 years ago

@gaviriar I think something is a bit off in your project file for this workaround, just tested building for 4.7.2 using:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp2.1;net472</TargetFrameworks>
    <RestoreAdditionalProjectSources>$(RestoreAdditionalProjectSources);https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreAdditionalProjectSources>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(TargetFramework)' == 'net472' ">
    <FrameworkPathOverride>$(PkgMicrosoft_TargetingPack_NETFramework_v4_7_2)\lib\net472\</FrameworkPathOverride>
  </PropertyGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
    <PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.7.2" Version="1.0.0" ExcludeAssets="All" PrivateAssets="All" GeneratePathProperty="true" />
  </ItemGroup>
</Project>

Note that the GeneratePathProperty metadata on PackageReference is only available in VS 15.9 / CLI 2.1.500+ (previews).

aggieben commented 6 years ago

This technique doesn't seem to work right for me, quite (on macOS):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
    <FrameworkPathOverride>$(NuGetPackageRoot)microsoft.targetingpack.netframework.v4.6.1\1.0.1\lib\net461\</FrameworkPathOverride>
  </PropertyGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'net461'">
    <PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.6.1" Version="1.0.1" />
  </ItemGroup>
</Project>

The top of the stack of errors:

/usr/local/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): error MSB4018: The "ResolveAssemblyReference" task failed unexpectedly. [/Users/ben/proj/oss/true-myth-csharp/src/TrueMyth/TrueMyth.csproj]
/usr/local/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(2110,5): error MSB4018: System.InvalidOperationException: Metadata image doesn't represent an assembly. [/Users/ben/proj/oss/true-myth-csharp/src/TrueMyth/TrueMyth.csproj]

Maybe has something changed since this workaround was first suggested? Is my path override incorrect?

JoseFMP commented 5 years ago

I am also interested to know. It has been a while since this issue is around. Wondering if any solutions are available in the meantime.

RehanSaeed commented 5 years ago

@dsyme's solution (slightly modified below) seems to work perfectly on Ubuntu and Mac using Azure DevOps.

<PropertyGroup Label="Build net4xx on Mono" Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
    <!-- See https://www.cafe-encounter.net/p2312/multi-targetting-net-framework-and-net-core-in-a-single-project -->
    <!-- When compiling .NET Core SDK 2.0 projects targeting .NET 4.x.x on Mono using 'dotnet build' you have to -->
    <!-- tell MSBuild where the Mono copy of the reference assemblies is. Looks in the standard install locations. -->
    <BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
    <BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
    <BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
    <!-- If we found Mono reference assemblies, then use them. -->
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
    <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net472'">$(BaseFrameworkPathOverrideForMono)/4.7.2-api</FrameworkPathOverride>
    <EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
    <!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
    <AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
</PropertyGroup>

However, this does not work with net472 on a Mac. Ubuntu seems to work fine for some reason.

nguerrera commented 5 years ago

The path forward here is https://github.com/dotnet/designs/pull/33#issuecomment-489264196

Please try those packages. We will not be investigating issues with workarounds like above.

YairHalberstadt commented 5 years ago

Based on https://github.com/dotnet/designs/pull/33#issuecomment-489264196, All I had to do was add

  <ItemGroup>
    <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies"
                      Version="1.0.0-preview.2"
                      PrivateAssets="All" />
  </ItemGroup>

To the csproj I was trying to build, and everything worked!

dsplaisted commented 4 years ago

The 1.0.0 versions of the reference assembly packages are now available. I'm going to close this issue, and I've created #4009 to track the further work of referencing these packages automatically.