[英]Is it possible to use a new SDK-style .csproj file for a UWP project?
有沒有人為使用新 SDK 樣式的.csproj
格式的 UWP 項目成功創建了.csproj
文件? 我從這個關於 WPF 的問題中汲取了靈感, 這讓我獲得了 90% 的成功。
在那之后,我開始使用MSBuild.Sdk.Extras 包,它讓我可以將uap10.0
作為<TargetFramework>
,經過一些調整后,我實際上使用以下.csproj
編譯了它:
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<!--UWP-specific properties-->
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17134.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
<TargetFrameworks>uap10.0</TargetFrameworks>
<OutputType>AppContainerExe</OutputType>
<LanguageTargets>$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets</LanguageTargets>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<PackageCertificateKeyFile>Test.UWP_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>bin\x86\Debug\</OutputPath>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<PlatformTarget>x86</PlatformTarget>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<ItemGroup>
<!--XAML stuff-->
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
<Page Include="**\*.xaml" Exclude="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Update="**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<!--Local projects-->
<!--Nuget references-->
</ItemGroup>
</Project>
但是,仍然存在一些問題:
/bin
目錄似乎不包含依賴項 .dll。 (左側為自定義項目的 /bin 目錄,右側為庫存 UWP 項目。)...這導致生成的 .exe 在啟動時立即崩潰。
有沒有人有關於如何把這件事帶到終點線的建議?
~EDIT MARK II:~ 目前的目標似乎是通過發布 WinUI 3.0 來支持 .NET Core 3(這意味着新的 .csproj 風格),該版本的目標是“2020 年的某個時間”發布。
而且,如果鏈接失效,第一個是指向 WinUI GitHub 問題的鏈接,WinUI 項目的 PM 說
我們當前的計划是托管 WinUI 3 應用程序在發布時使用 .NET Core 3 而不是 .NET Native。
第二個鏈接是 WinUI 項目的路線圖,它說:
我們計划在 2020 年發布 WinUI 3.0。
和
2.預覽版:我們計划在 2020 年上半年發布更完整的預覽版
~編輯:~在 Build 2019 上有一些安靜的公告,隨着 .NET Core 3 的發布,UWP 將開始在 .NET Core 運行時上運行。這似乎涉及到 UWP 項目轉向新的 .csproj 樣式,因為好。
原帖:
現在看來,答案是否定的。 根據制作 MS Build SDK Extras 的聰明女士Claire Novotny :
目前不能將 SDK 樣式項目用於應用程序本身,只能用於 UWP 類庫。 項目系統也需要支持以正確的方式部署和啟動它。
第三方sdk,參見novotnyllc/MSBuildSdkExtras:MSBuild SDK項目的額外屬性
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>net46;uap10.0.16299;tizen40</TargetFrameworks>
</PropertyGroup>
</Project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.