简体   繁体   English

如何从命令行重现 Visual Studio ClickOnce 发布

[英]How to reproduce Visual Studio ClickOnce publish from command line

Visual Studio 2022 中的“发布”按钮

I have been publishing my app by clicking the Publish button in the VS2022 project Publish tool.我一直在通过单击 VS2022 项目发布工具中的发布按钮来发布我的应用程序。 I want to recreate the same behaviour from the command line.我想从命令行重新创建相同的行为。

My C# project targets .NET 6.0, and my.pubxml has <PublishProtocol>ClickOnce</PublishProtocol> .我的 C# 项目目标是 .NET 6.0,而 my.pubxml 有<PublishProtocol>ClickOnce</PublishProtocol>

These docs sound like they should document what I need, but the suggested variations on msbuild /target:publish absolutely do not produce the same result as clicking the button in VS: 这些文档听起来应该记录我需要的内容,但是msbuild /target:publish上的建议变体绝对不会产生与在 VS 中单击按钮相同的结果:

  • The <PublishDir> and <PublishUrl> from the.pubxml are ignored.来自 the.pubxml 的<PublishDir><PublishUrl>被忽略。
  • The <ApplicationRevision> is not updated even when <IsRevisionIncremented> is true.即使<IsRevisionIncremented>为真, <ApplicationRevision>也不会更新。
  • Most importantly, the output is missing the main MyApp.application file and the Application Files folder.最重要的是,output 缺少主要的MyApp.application文件和Application Files夹。

The <PublishDir> and <PublishUrl> from the.pubxml are ignored.来自 the.pubxml 的<PublishDir><PublishUrl>被忽略。

The <ApplicationRevision> is not updated even when is true. <ApplicationRevision>即使为真也不会更新。

Most importantly, the output is missing the main MyApp.application file and the Application Files folder.最重要的是,output 缺少主要的 MyApp.application 文件和 Application Files 文件夹。

For the first and the third requirement, using the below command will solve the issue:对于第一个和第三个要求,使用以下命令将解决问题:

msbuild -t:restore 

msbuild /target:publish /p:Configuration=publish /p:PublishProfile=Properties\PublishProfiles\ClickOnceProfile.pubxml /p:PublishDir=bin\Release\net6.0-windows\app.publish\ /p:PublishUrl="bin\publish\"

Result:结果:

在此处输入图像描述

在此处输入图像描述

For the second requirement, the value didn't increase is totally expected, because it is not automatically incremented for builds performed at the command-line.对于第二个要求,该值没有增加是完全可以预料的,因为它不会在命令行执行的构建中自动增加。 See this official document:看这个官方文档:

Publish Properties 发布属性

在此处输入图像描述

Increase this value need based on IDE, pure msbuild command can't achieve this.增加这个值需要在IDE的基础上,单纯的msbuild命令是做不到的。

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

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