dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.95k stars 4.9k forks source link

Building UAP project does not work on Visual Studio Mac, understandably... #4012

Closed olivegamestudio closed 4 years ago

olivegamestudio commented 4 years ago

I'm trying to multi-targeting on my Mac, and I can do the first three targets but UAP is a non-starter.

Is there anyway to ignore this platform if it doesnt exist? Is there another way to do this without creating another project? Is there something i missed a different target perhaps?

I apologise if this is not the right location for this issue.

Example:

<Project Sdk="MSBuild.Sdk.Extras/2.0.54">

  <PropertyGroup>
    <TargetFrameworks>xamarinios10;monoandroid71;net461;uap</TargetFrameworks>
  </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="MSBuild.Sdk.Extras" Version="2.0.54" />  
    </ItemGroup>

</Project>
scalablecory commented 4 years ago

@safern @ViktorHofer is there some conditional statement that can be used here?

safern commented 4 years ago

I don't think there is a way to know if the tfm is supported for the current built OS via a property. However there is a property that MSBuild populates to tell you which OS you're building on. So basically you could condition based on that.

You could do something like:

<PropertyGroup>
  <TargetFrameworks>xamarinios10;monoandroid71</TargetFrameworks>
  <TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net461;uap</TargetFrameworks>
</PropertyGroup>
ViktorHofer commented 4 years ago

What @safern says makes most sense. Community members ued the same mechanism for .NET Framework back when reference assemblies weren't available for it.

ViktorHofer commented 4 years ago

Closing as question is answered. Feel free to reopen if you disagree.