问题描述
使用IDE发布的ClickOnce正常运行.
ClickOnce publish with IDE works normal.
当尝试通过MSBuild命令行发布时
When trying to publish via MSBuild command line
%MSBUILD% /target:publish /p:Configuration=Release;PublishDir="REMOTE_FOLDER"
仅复制Project.exe
和Setup.exe
.
当尝试执行%MSBUILD% /target:publish
命令时,所有必需的文件都将复制到build\app.publish
文件夹
When try to %MSBUILD% /target:publish
command then all necessary files copies to the build\app.publish
folder
如何通过命令行发布IDE使用的相同ClickOnce设置
How do I publish via command line same ClickOnce settings which IDE uses
PS 这个问题类似,但不一样
PS this question similar but not the same
推荐答案
某些功能是由Visual Studio而不是由MSBuild命令行完成的.因此,从命令行执行单击一次部署时,其行为会有所不同.
Some features are done by Visual-Studio and not by the MSBuild command line. So the click-once-deployment behaves differently when it's executed from the command-line.
如果要通过命令行发布IDE使用的相同ClickOnce设置,则可以使用自定义目标来实现.编辑您的project(csproj)
文件(右键单击项目节点->卸载项目->编辑xxx.csproj),然后在其中添加以下代码:
If you want to publish via command line same ClickOnce settings which IDE uses, you can use a custom target to achieve it. Edit your project(csproj)
file (right click project node -> unload project -> edit xxx.csproj) and add the following code in it:
<PropertyGroup>
<ProjLocation>D:\Test\Projects\ClickOncePublish\ClickOncePublish</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Debug</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<DeploymentFolder>D:\Test\Publish\</DeploymentFolder>
</PropertyGroup>
<Target Name="Test" DependsOnTargets="Clean">
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Publish"/>
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*"/>
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(SetupFiles)" DestinationFolder="$(DeploymentFolder)\" />
<Copy SourceFiles="@(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"/>
</Target>
<Target Name="Clean">
<Message Text="Clean project" />
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Clean"/>
</Target>
然后,您可以使用MSBuild命令行构建项目:
Then you can build the project with the MSBuild command line:
msbuild /target:test
执行build命令后,所有期望的文件都会通过命令行使用与IDE使用的相同的ClickOnce设置发布.
After execute the build command, all the expected files are publish via command line same ClickOnce settings which IDE uses.
注意:您应将ProjLocation
的值更改为项目的路径.
Note: You should change the value of ProjLocation
to the path of your project.
这篇关于使用命令行发布ClickOnce时缺少ApplicationFiles文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!