简体   繁体   English

在命令行中构建UWP应用(使用MSBUILD)

[英]Building UWP app in command line (using MSBUILD)

I am trying to build UWP app (targeting 16299) from command line from Jenkins setup. 我正在尝试从Jenkins安装程序的命令行构建UWP应用(目标16299)。 The system has only VS build tools 2017. used this command to build 系统仅具有VS构建工具2017。使用此命令进行构建

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" /t:Rebuild /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86\x64\ARM" /p:BuildAppxUploadPackageForUap=true SOLUTION_FILE.sln 

error MSB4226: The imported project "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\Microsoft\\WindowsXaml\\v15.0\\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. 错误MSB4226:找不到导入的项目“ C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ BuildTools \\ MSBuild \\ Microsoft \\ WindowsXaml \\ v15.0 \\ Microsoft.Windows.UI.Xaml.CSharp.targets”。 Also, tried to find "Microsoft\\WindowsXaml\\v15.0\\Microsoft.Windows.UI.Xaml.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\\Program Files (x86)\\MSBuild" . 此外,尝试在$(MSBuildExtensionsPath)的后备搜索路径中找到“ Microsoft \\ WindowsXaml \\ v15.0 \\ Microsoft.Windows.UI.Xaml.CSharp.targets”-“ C:\\ Program Files(x86)\\ MSBuild”。 These search paths are defined in "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe.Config". 这些搜索路径在“ C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ BuildTools \\ MSBuild \\ 15.0 \\ Bin \\ MSBuild.exe.Config”中定义。 Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. 确认声明中的路径正确,并且文件在搜索路径之一中的磁盘上存在。

Another issue found is nuget is not restoring any package, so updated nuget to 4.4.1 then I got the error 发现的另一个问题是nuget没有还原任何软件包,因此将nuget更新为4.4.1,然后我得到了错误

MSBuild auto-detection: using msbuild version '15.5.180.51428' from 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\bin'. MSBuild自动检测:使用来自'C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ BuildTools \\ MSBuild \\ 15.0 \\ bin'的msbuild版本'15 .5.180.51428'。 Nothing to do. 没事做。 None of the projects in this solution specify any packages for NuGet to restore. 此解决方案中的任何项目均未指定要还原NuGet的任何程序包。

same issue with nuget 4.6.0 also nuget 4.6.0也有同样的问题

I tried by adding following in project file 我尝试通过在项目文件中添加以下内容

<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> </PropertyGroup>

same issue with msbuild and nuget, anyone succeed in building UWP in Jenkins? 与msbuild和nuget相同的问题,有人在Jenkins中成功构建UWP吗?

Update 05-01-2015 更新2015年5月1日

  • Followed instruction according to answer. 根据答案遵循指示。
  • Copied NuGet folder 复制的NuGet文件夹
  • Copied the "WindowsXaml" folder. 复制了“ WindowsXaml”文件夹。
  • Used MSbuild restore instead of Nuget restore to fix msbuild trying to find packages in "C:\\WINDOWS\\system32\\config\\systemprofile.nuget\\packages\\" 使用MSbuild还原而不是Nuget还原来修复msbuild试图在“ C:\\ WINDOWS \\ system32 \\ config \\ systemprofile.nuget \\ packages \\”中查找软件包的情况

With all these changes no more issues in build, But the appx bundle is not present. 通过所有这些更改,构建中不再存在任何问题,但是appx捆绑包不存在。 may be individual appx for x86/x64/ARM has to be created and then some kind of merging is required. 可能是必须为x86 / x64 / ARM创建单独的appx,然后需要某种合并。

so need further investigations 所以需要进一步调查

From the directory path that you have for MSBuild, I see that you may have installed MSBuildTools installer instead of the community, professional,... editions. 从您用于MSBuild的目录路径中,我看到您可能已经安装了MSBuildTools安装程序,而不是社区,专业...版本。

I tried that before and found that it's incomplete and doesn't have all dependencies for building Uwp tools, take a look at some of the comments here about the issues. 我之前曾尝试过,但发现它不完整,并且不具有构建Uwp工具的所有依赖关系,请查看此处有关问题的一些评论。

First Workaround: You can install Uwp Workload from VS Community or Professional as it has all dependencies, till Microsoft fix the issues in BuildTools installer. 第一种解决方法:您可以从VS Community或Professional安装Uwp Workload,因为它具有所有依赖性,直到Microsoft在BuildTools安装程序中修复问题为止。

Bonus: if you want to run the installer from command line, you can compose command line like that: 奖励:如果要从命令行运行安装程序,则可以编写如下命令行:

vs_installer.exe --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" ^
--add Microsoft.VisualStudio.Workload.Universal ^
--add Microsoft.VisualStudio.Component.Windows10SDK.14393 ^
--add Microsoft.Component.MSBuild ^
--passive --wait --norestart

The longer workaround, I managed to install other dependencies but I believe it's kind of hassle if you are automating this installation, snippets from this article 较长的解决方法是,我设法安装了其他依赖项,但如果您要自动执行此安装,我相信这很麻烦, 本文的摘录

Copy the Sdks folder from a machine that has VS2017 installed at: c:\\Program Files(x86)\\Visual Studio\\2017\\Professional\\Build MSBuild\\Sdks to your build machine at: c:\\Program Files(x86)\\Visual Studio\\2017\\Build Tools\\MSBuild\\Sdks 从安装了VS2017的计算机上将Sdks文件夹复制到:c:\\ Program Files(x86)\\ Visual Studio \\ 2017 \\ Professional \\ Build MSBuild \\ Sdks到构建计算机上\\ 2017 \\ Build Tools \\ MSBuild \\ Sdks

And for the nuggets issue: 对于金块问题:

Copying the NuGet import files will do the tr Again, from a machine with VS2017, copy the following folder: C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\NuGet to your build machine at: C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\IDE\\CommonExtensions\\Microsoft\\NuGet 复制NuGet导入文件将完成tr,再次从装有VS2017的计算机上复制以下文件夹:C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ Common7 \\ IDE \\ CommonExtensions \\ Microsoft \\ NuGet在以下位置生成计算机:C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ BuildTools \\ Common7 \\ IDE \\ CommonExtensions \\ Microsoft \\ NuGet

Note: If you come by this later and found that Microsoft fixed the issues related to Uwp in MSBuildTools installer, please leave a comment about it in this answer to update it. 注意:如果稍后遇到此问题,并且发现Microsoft在MSBuildTools安装程序中解决了与Uwp相关的问题,请在此答案中对此发表评论以进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从命令行构建时,MSBuild警告MSB3884 - MSBuild Warning MSB3884 when building from command line 如何在 Jenkins 中使用 MSBuild 命令行覆盖目标文件 - how to overwrite destination file(s) using MSBuild command line in Jenkins 使用msbuild命令行转换web.config - transform web.config using msbuild command line 在 jenkins 上使用 msbuild 构建 Xamarin iOS 应用程序时 IPA 中缺少资产 - Missing assets in IPA when building Xamarin iOS app using msbuild on jenkins 使用BitBucket和Jenkins和MSBUILD构建功能分支 - Building Feature Branches using BitBucket and Jenkins and MSBUILD 命令行MSBUILD PreBuildEvent,用于安装凉亭 - Command line MSBUILD PreBuildEvent for bower install 使用Jenkins MSBuild插件命令行将VS2010解决方案发布到ISS(本地) - Publish VS2010 Solution to ISS(local) using Jenkins MSBuild Plugin command line 使用&#39;npx microbundle&#39;命令在jenkins中构建nodejs应用程序gettig错误 - Building nodejs app in jenkins using 'npx microbundle' command gettig error msbuild 的行为与命令行和 Jenkins 不同 - msbuild behaving differently from command line vs Jenkins 使用MSBuild从Jenkins构建.NET标准库 - Building .NET Standard Library from Jenkins using MSBuild
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM