简体   繁体   中英

How to make JavaScript App (jsproj) generate APPX in post-build step

I added the following to my JavaScript app project file to cause MSBuild to build APPX package:

 <Target Name="AfterBuild">
    <Exec Command="$(MSBuildToolsPath)\MSBuild.exe $(ProjectPath) /p:Configuration=$(Configuration);Platform=$(Platform)"/>
 </Target>

Unfortunately this starts an infinite loop where MSBuild builds the project, encounters this AfterBuild target and calls itself again. I can't think of how to fix this. Creating a marker file won't work because APPX will never get re-generated after the first time and will be out of date. Is there an environment variable that can distinguish when MSBuild is building the project versus it being built in Visual Studio? Sorry, I'm stumped on this one.

Turns out the solution is simple, just add the following to the project file instead of messing with AfterBuild target:

<PropertyGroup Label="Globals">
   <GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
</PropertyGroup>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM