MSBuild 失败。缺少 Release/WinRTXamlToolkit

MSBuild failing. Missing Release/WinRTXamlToolkit

尝试使用 msbuild 构建 Windows 8.1 商店应用程序,但出现错误。这是我与 msbuild 的第一次较量,我对文档的运气并不好,因为它似乎都利用了 UWP 特定的东西。我得到的错误是

C:\git\adr\win8app\src\AppDataRoom.WinRT.Adr\AppDataRoom.WinRT.Adr.csproj" (default target) (1) -> (_GenerateAppxPackageRecipeFile target) -> C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2156,5): error APPX0702: Payload file 'C:\app\bin\x64\Release\WinRTXamlToolkit\WinRTXamlToolkit.xr.xml' do es not exist.

bin\x64\Release 文件夹中丢失 WinRTXamlToolkit 相关的所有错误之后还有 25 个其他错误

我的 msbuild 命令我 运行 是:

msbuild .\app.csproj /p:Configuration="Release" /p:Platform="x64

我知道 WinRTXamlToolKit 是一个 nuget 包,我可以在发布文件夹中看到 dll,但是我该怎么做才能解决这个错误?我错过了什么?

我最终找到了解决方案(尽管它仍然感觉有点老套)。我最终将所有内容都包装在一个 powershell 脚本中。该脚本首先恢复项目 nuget 包,以防它由于某种原因不存在。然后脚本将 WinRTXamlToolKit 文件夹从包复制到 bin/x64/Release 文件夹,然后我 运行 MSBuild 命令,现在一切似乎都正确构建。这是脚本的样子(我不经常编写 powershell 脚本,所以我的约定可能不是最好的)

#create some alias

$nugetPath = $sourceControlRoot + ".nuget/nuget.exe";
$nugetPackagesPath = $sourceControlRoot + "/packages/";
$projectPath = $sourceControlRoot + "/TestingProject/"
Set-Alias nuget  $nugetPath 

#Nuget Restore
$solutionPath = $sourceControlRoot + "/TestingProject.sln"
nuget restore $solutionPath


#To Help MSBuild we need to copy the WinRTXamlToolkit into the bin/Release folders
$winRtXamlToolkitPath = $nugetPackagesPath + "WinRTXamlToolkit.1.6.1.3/lib/netcore451/WinRTXamlToolkit"
$copyOutput64 = $projectPath + "bin/x64/Release/WinRTXamlToolkit"
$copyOutput86 = $projectPath + "bin/x86/Release/WinRTXamlToolkit"
$testPath = $copyOutput64

if (!(Test-Path $testPath )) {
    Copy-Item $winRtXamlToolkitPath $copyOutput64 -recurse
    Copy-Item $winRtXamlToolkitPath $copyOutput86 -recurse
    Write-Output "WinRTXamlToolkit copied into bin folders"
}

#build the project
$buildPath = $projectPath + "TestingProject.csproj"
msbuild $buildPath /p:Configuration="Release" /p:Platform="x64"