【发布时间】:2018-09-28 13:57:10
【问题描述】:
是否有人为使用新 SDK 样式 .csproj 格式的 UWP 项目成功创建了 .csproj 文件?我从this question 中获得了关于 WPF 的灵感,这让我了解了 90% 的情况。
在那之后,我开始使用MSBuild.Sdk.Extras package,它使我能够以<TargetFramework> 的形式访问uap10.0,经过一些调整,我得到了它实际上是用以下.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 项目。)
- Visual Studio 的智能感知抱怨内置 XAML 类型不受支持。
...这会导致生成的 .exe 在启动时立即崩溃。
有没有人对如何让这个东西到达终点有建议?
【问题讨论】:
-
在微软更新所有工具之前,请这样并不容易。像github.com/onovotny/MSBuildSdkExtras 这样的尝试还需要时间来足够成熟。
-
哦,当然。我真的不期待一帆风顺。只是想弄清楚我缺少哪些步骤。 UWP 构建过程非常不透明。