2017-07-29 72 views
1

我試圖從命令行構建一個UWP應用程序,以便將檢查到構建自動化到發佈到應用商店。在Visual Studio中運行構建時,以及在創建應用程序包時,一切運行正常(但需要15分鐘左右,時間太長)。使用MSBuild(GENERATEPROJECTPRIFILE)構建UWP應用程序問題

在調用每個平臺(86,64 & ARM)的MSBuild,只有ARM似乎失敗,出現以下錯誤:

_CreatePriConfigXmlForSplitting 

"C:\Source\MyProject\src\MyProject\MyProject.csproj" (Build target) (1) -> 
(_SplitResourcesPri target) -> 
    error PRI175 : 0x80070002 - Processing Resources failed with error : The system cannot find the file specified. [C:\Source\MyProject\src\MyProject\MyProject.csproj] 
    GENERATEPROJECTPRIFILE : error PRI252: 0xdef00071 - File C:\Source\MyProject\output\Release\x86\arm\MyProject\resources.pri not found. [C:\Source\MyProject\src\MyProject\MyProject.csproj] 

    0 Warning(s) 
    2 Error(s) 

正如你可能已經注意到,它使用x86\arm目錄而不是arm,從而構建失敗了。

我使用Cake建立這個,下面是(相關部分)的腳本:

Task("Build") 
    .IsDependentOn("Clean") 
    .IsDependentOn("UpdateVersion") 
    .IsDependentOn("RestorePackages") 
    .Does(() => 
{ 
    var platforms = new Dictionary<string, PlatformTarget>(); 
    platforms["ARM"] = PlatformTarget.ARM; 
    platforms["x86"] = PlatformTarget.x86; 
    platforms["x64"] = PlatformTarget.x64; 

    foreach (var platform in platforms) 
    { 
     Information("Building project for platform {0}", platform.Key); 

     var outputDirectory = "../../" + outputRootDirectory + "/" + platform.Value.ToString(); 
     var projectFileName = string.Format("./src/{0}/{0}.csproj", solutionName); 

     var msBuildSettings = new MSBuildSettings { 
      Verbosity = Verbosity.Diagnostic, // Verbosity.Minimal 
      ToolVersion = MSBuildToolVersion.VS2017, 
      Configuration = configurationName, 
      MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform 
      PlatformTarget = platform.Value 
     }; 

     // Need special path since this is relative to the project file, not the cake build directory 
     //msBuildSettings.Properties["OutputPath"] = new List<string>(new [] { outputDirectory }); 

     // We don't create native builds, we will use MSIL builds which the store will recompile, 
     // for more info see https://oren.codes/2015/12/03/continuous-integration-for-uwp-projects-making-builds-faster/ 
     msBuildSettings.Properties["UseDotNetNativeToolchain"] = new List<string>(new [] { "false" }); 
     msBuildSettings.Properties["BuildAppxUploadPackageForUap"] = new List<string>(new [] { "true" }); 
     //msBuildSettings.Properties["AppxPackageArtifactsDir"] = new List<string>(new [] { outputDirectory }); 

     // Fix for broken targets 
     //msBuildSettings.Properties["ProjectPriFileName"] = new List<string>(new [] { "resources.pri" }); 
     //msBuildSettings.Properties["ProjectPriFullPath"] = new List<string>(new [] { outputDirectory + "/resources.pri" }); 
     //msBuildSettings.Properties["_TransformedProjectPriFullPath"] = new List<string>(new [] { outputDirectory + "/resources.pri" }); 

     MSBuild(projectFileName, msBuildSettings); 
    } 
}); 

A.正如你看到的,我通過手動更改MS建立性能試驗了一下,但沒有迄今爲止的運氣。

B.起初我以爲這是GenerateProjectPriFile任務失敗。然而,經過一番調查,我發現,創建劃分的文件已經表明使用錯誤的startIndexAt值:

<?xml version="1.0" encoding="utf-8"?> 
<resources targetOsVersion="10.0.0" majorVersion="1"> 
    <packaging> 
    <autoResourcePackage qualifier="Language" /> 
    <autoResourcePackage qualifier="Scale" /> 
    <autoResourcePackage qualifier="DXFeatureLevel" /> 
    <omitSchemaFromResourcePacks /> 
    </packaging> 
    <index root="\" startIndexAt="C:\Source\MyProject\output\Release\x86\arm\MyProject\resources.pri"> 
    <default> 
     <qualifier name="Language" value="en-US" /> 
     <qualifier name="Contrast" value="standard" /> 
     <qualifier name="Scale" value="200" /> 
     <qualifier name="HomeRegion" value="001" /> 
     <qualifier name="TargetSize" value="256" /> 
     <qualifier name="LayoutDirection" value="LTR" /> 
     <qualifier name="DXFeatureLevel" value="DX9" /> 
     <qualifier name="Configuration" value="" /> 
     <qualifier name="AlternateForm" value="" /> 
     <qualifier name="Platform" value="UAP" /> 
    </default> 
    <indexer-config type="PRI" /> 
    </index> 
</resources> 

我不知道爲什麼它建設ARM ARM時預先考慮前86。任何幫助表示讚賞。與此同時,如果我找到新的東西,我會繼續調查並更新這篇文章。

回答

1

看起來我必須指定sln文件,而不是csproj文件。這有點不幸,因爲現在它的構建遠遠超過它的需求(在同一解決方案中有多個項目),但我可以通過創建自定義MyProject.Build.sln文件來解決這個問題

+0

所以澄清..這是一個蛋糕問題,還是直接從命令行構建時也會出現這個問題? –

+1

不是一個蛋糕問題,它是msbuild魔術,我找不到任何體面的文檔(但那仍然可以是我) –