MSBuild is not generating publish web page (ClickOnce)

懵懂的女人 提交于 2019-12-01 03:16:20

I found a good solution here. You can use a template for publish.htm with {VERSION} placeholder inside. MSBuild Community Tasks are required for the FileUpdate task.

BUILD_VERSION - environment variable, set by my build script. PublishDir property is set in argument for msbuild.

  <!-- .... -->

  <Target Name="DoPublish">
    <MSBuild Projects="$(ProjectFileName)" Targets="Publish" Properties="ApplicationVersion=$(BUILD_VERSION)" />
    <!-- Write publish.htm file for ClickOnce -->
    <Copy SourceFiles="$(ProjectDir)\publish.htm" DestinationFiles="$(PublishDir)\publish.htm"/>
    <FileUpdate Files="$(PublishDir)\publish.htm"
                IgnoreCase="true"
                Multiline="true" 
                Singleline="false"
                Regex="{VERSION}" 
                ReplacementText="$(BUILD_VERSION)"/>
  </Target>

</Project>

I'm using Visual Studio 2015, but otherwise had what sounds like the same or similar issue. The solution was to open the Properties of the Project file in Visual Studio, go to the "Publish" settings, and on the right click [Options...]. This will open up the "Publish Options" dialog. Select "Deployment" and if you see the "Deployment web page" is empty (mine was) then enter "publish.htm", you should then be able to check "Automatically generate deployment web page after every publish" (you need to check this). Click [OK] to close the dialog and then republish. Your "publish.htm" file should now appear.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!