我正在尝试使用Cake构建一个UWP应用程序(使用VS2017创建)。 我得到了几个"无法加载文件或程序集System.Private.CoreLib ...."构建阶段的异常。
重现的步骤: 创建名为&#34的UWP应用程序;示例"在./src目录下的VS2017中,并使用以下cake脚本来构建:
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
var target = Argument("target", "default");
var configuration = Argument("configuration", "Release");
var buildDir = Directory("./src/Example/bin") + Directory(configuration);
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./src/Example.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(IsRunningOnWindows())
{
MSBuild("./src/Example.sln", settings =>
settings.SetConfiguration(configuration));
}
});
Task("Default")
.IsDependentOn("Build");
RunTarget(target);
//更新:
构建阶段的前几个日志语句:
Executing task: Build
Executing: "C:/Program Files (x86)/Microsoft Visual
Studio/2017/Community/MSBuild/15.0/Bin/amd64/MSBuild.exe" /v:normal /p:Configuration="Release" /target:Build "C:/Users/jannik/Documents/Visual Studio 2017/Projects/example/src/Example.sln
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
第一个错误如下:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1254,5): error MSB3816: Loading assembly "C:\Users\jannik\.nuget\packages\runtime. Private.Uri\4.0.2\runtimes\aot\lib\netcore50\System.Private.Uri.dll" failed. System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7 r one of its dependencies. The system cannot find the file specified.\r [C:\Users\jannik\Documents\Visual Studio 2017\Projects\example\src\Example\Example.csproj]