繁体   English   中英

是否可以为 UWP 项目使用新的 SDK 样式的 .csproj 文件?

[英]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>

但是,仍然存在一些问题:

  • 在比较库存 UWP 项目和我的自定义项目时,自定义项目的已编译/bin目录似乎不包含依赖项 .dll。 (左侧为自定义项目的 /bin 目录,右侧为库存 UWP 项目。)

比较结果 /bin 目录的图像

  • Visual Studio 的智能感知抱怨不支持内置 XAML 类型。

...这导致生成的 .exe 在启动时立即崩溃。

有没有人有关于如何把这件事带到终点线的建议?

Visual Studio 错误消息

~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 类库。 项目系统也需要支持以正确的方式部署和启动它。

似乎答案是否定的

https://github.com/dotnet/sdk/issues/1408

显然

目前没有计划支持这一点。

第三方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.

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