我正在尝试从命令行构建一个UWP应用程序,以便从签入到发布到商店自动化构建。从Visual Studio中运行构建时,一切正常,当我创建应用程序包时,一切正常(但需要很长时间,15分钟左右)。
在调用每个平台的msbuild(x86,x64和ARM)时,只有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);
}
});
一个。正如您所看到的,我通过手动覆盖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之前预先设置了x86。任何帮助表示赞赏。与此同时,如果我找到新的东西,我会继续调查和更新这篇文章。
答案 0 :(得分:1)
看起来我必须指定sln
文件,而不是csproj
文件。这有点不幸,因为它现在构建的内容远远超过它所需要的(同一解决方案中有多个项目),但我可以通过创建自定义MyProject.Build.sln
文件来解决这个问题