MSBuild失败。缺少版本/ WinRTXamlToolkit

时间:2017-10-17 16:48:53

标签: c# visual-studio-2015 msbuild windows-runtime appx

尝试使用Windows 8.1构建msbuild商店应用,但收到错误消息。这是我与msbuild的第一次战斗,我对文档没有太多运气,因为它似乎都利用了UWP具体的东西。我得到的错误是

  

C:\ git \ adr \ win8app \ src \ AppDataRoom.WinRT.Adr \ AppDataRoom.WinRT.Adr.csproj“(默认目标)(1) - >   (_GenerateAppxPackageRecipeFile target) - >     C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v14.0 \ AppxPackage \ Microsoft.AppXPackage.Targets(2156,5):错误   APPX0702:有效载荷文件'C:\ app \ bin \ x64 \ Release \ WinRTXamlToolkit \ WinRTXamlToolkit.xr.xml'做   不存在。

WinRTXamlToolkit文件夹内部遗漏bin\x64\Release所有相关的其他25个错误

我正在运行的msbuild命令是:

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

我理解WinRTXamlToolKit是一个nuget包,我可以在release文件夹中看到dll,但是如何解决这个错误呢?我错过了什么?

1 个答案:

答案 0 :(得分:1)

我最终找到了一个解决方案(虽然它仍然感觉有点hacky)。我最终将所有内容都包含在一个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"
相关问题