【发布时间】:2020-08-11 11:41:49
【问题描述】:
我有一个 PCL 项目,每个平台都有不同的功能和类。我现在想实现 .net 核心支持。但我不能使用像UserControl 这样的控件,因为没有引用Microsoft.NET.Sdk.WindowsDesktop SDK。 .net 框架很容易实现,因为我只需要引用每个程序集...但是在 .net core 中,我无法引用程序集...
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;xamarin.ios10;xamarin.mac20;xamarin.tvos10;monoandroid10.0;tizen40</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">uap10.0.17763;net472;netcoreapp3.1;$(TargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('net4')) And '$(OS)' == 'Windows_NT' ">
...
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netcoreapp3')) And '$(OS)' == 'Windows_NT' ">
...
<SDKReference Include="Microsoft.NET.Sdk.WindowsDesktop" />
</ItemGroup>
这是我的可执行应用程序,引用上面的 PCL 项目;
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference ...... />
</ItemGroup>
</Project>
我已经尝试过这个来引用 SDK,但它不起作用。
<SDKReference Include="Microsoft.NET.Sdk.WindowsDesktop" />
【问题讨论】:
-
我有一个解决方案,你可以查看我的答案。
标签: c# visual-studio .net-core msbuild sdk