简体   繁体   English

使用VS2017样式的csproj定位Xamarin Mobile Mac

[英]Targeting Xamarin Mobile Mac using VS2017-style csproj

I like the new 'msbuild pack' nuget package generation in VS2017. 我喜欢VS2017中新的“ msbuild pack” nuget软件包。 I would like to use it to generate a library that uses Xamarin.Mac to be consumed by Xamarin Mobile Mac projects. 我想用它来生成一个使用Xamarin.Mac的库,以供Xamarin Mobile Mac项目使用。 I tried 我试过了

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

  <PropertyGroup>
    <TargetFrameworks>Xamarin.Mac</TargetFrameworks>
  </PropertyGroup>

</Project>

but I get 但我明白了

Severity    Code    Description Project File    Line    Suppression State
Error       Cannot infer TargetFrameworkIdentifier and/or TargetFrameworkVersion from TargetFramework='Xamarin.Mac'. They must be specified explicitly. Kumquat.Common.Mac  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets    84  

This example ( https://github.com/Azure/azure-mobile-apps-net-client/blob/master/src/Microsoft.Azure.Mobile.Client/Microsoft.Azure.Mobile.Client.csproj ) has 该示例( https://github.com/Azure/azure-mobile-apps-net-client/blob/master/src/Microsoft.Azure.Mobile.Client/Microsoft.Azure.Mobile.Client.csproj )具有

<TargetFrameworks>netstandard1.4;net45;MonoAndroid71;Xamarin.iOS10;uap10.0</TargetFrameworks>

However, when I try Xamarin.iOS10 on my end, I get a similar error. 但是,当我尝试使用Xamarin.iOS10时,出现类似的错误。 Is there something special I need to install on my machine to get Xamarin.* as Target Frameworks? 为了将Xamarin。*用作目标框架,我需要在计算机上安装一些特殊的东西吗? I do have Xamarin installed. 我确实安装了Xamarin。 I have VS2017 (version 15.2). 我有VS2017(版本15.2)。

The Microsoft.NET.Sdk doesn't support automatic inference for this target framework yet. Microsoft.NET.Sdk尚不支持此目标框架的自动推断。 As you can see in the example you linked, they add the required definitions later in the same project: 正如您在链接的示例中看到的那样,它们稍后在同一项目中添加了必需的定义:

 <PropertyGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' "> <TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier> <TargetFrameworkVersion>v1.0</TargetFrameworkVersion> <LanguageTargets>$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.CSharp.targets</LanguageTargets> <DefineConstants>$(DefineConstants);PLATFORM_IOS;XAMARIN_AUTH_INTERNAL</DefineConstants> </PropertyGroup> 

The .NET Sdk has logic to infer TargetFrameworkIdentifier and TargetFrameworkVersion only for netstandard , netcoreapp and net at the moment (see the source ) .NET SDK目前具有仅针对netstandardnetcoreappnet推断TargetFrameworkIdentifierTargetFrameworkVersion逻辑(请参阅源代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM