2017-10-10 19 views
1

私はUWPアプリ(VS2017で作成)をCakeでビルドしようとしています。 ビルドフェーズで、いくつかの "ファイルをロードできませんでした"または "System.Private.CoreLib ....アセンブリ"の例外が発生しました。ケーキでUWPアプリを作成する

再現手順:

#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); 

//更新:

最初のいくつかのログステートメント は、構築するために./src dirと使用後のケーキのスクリプトの下にVS2017で "例" という名前のUWPのアプリを作成します。ビルドフェーズに:

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] 
+0

あなたが診断冗長でケーキを起動した場合、あなたはそれがMSBuildの15.xを使用していていることがわかりますか? https://stackoverflow.com/a/38658796/5883153 – devlead

+0

y MSBuild 15を使用しているようです – jannikb

答えて

2

エラーを再現できました。このpostは、MSBuildがコマンドラインからx64バージョンにデフォルト設定されていることに気がついたときに問題を明らかにしています。明示的にMSBuildプラットフォームをx86バージョンに設定することで、Cake DSLを使用して問題を解決することができました。以下は私がそれを働かせるために使用した設定です。 MSDNから

のx86は、Visual Studioでデフォルトで使用されるツールを構築してください。 C:\ Program Files(x86)\ MSBuild \ 12.0 \ bin \ amd64にあるAMD64 MSBuildツールの使用はお勧めしません。ビルドの問題を引き起こす可能性があります。

注:それは私が遭遇した非常に次のビルドエラーだったので、私は明示的にPlatformTargetを設定します。

settings .WithTarget("Publish") .SetVerbosity(Verbosity.Minimal) .UseToolVersion(MSBuildToolVersion.VS2017) .SetConfiguration(configuration) .SetMSBuildPlatform(MSBuildPlatform.x86) .SetPlatformTarget(PlatformTarget.x86) .WithProperty("AppxBundle","Always") .WithProperty("AppxBundlePlatforms","x86"))

関連する問題