我正在尝试制作一个批处理文件以一键发布我们拥有的少数 ClickOnce 应用程序。我为此使用了 msbuild,作为示例,下面的命令行显示了我是如何做的:
msbuild
MyApp.sln
/t:Publish
/p:Configuration=Release
/p:PublishUrl="C:\Apps\"
/v:normal > Log.txt
(包装方便阅读)
当我运行上述命令时,它会在发布目录中构建并发布应用程序,即 bin\release!知道为什么 msbuild 在我上面的例子中不尊重 PublishUrl 属性吗?
PS:我还尝试了不同的组合,包括删除“配置”,使用“重建”和“仅发布”作为目标,并删除引号但没有成功。
最佳答案
某些功能由 Visual-Studio 完成,而不是由 MSBuild 脚本完成。因此,当从命令行执行时,单击一次部署的行为会有所不同。
For example, you could set the PublishURL to an FTP path and set the InstallURL to a Web URL. In this case, the PublishURL is only used in the IDE to transfer the files, but not used in the command-line builds. Finally, you can use UpdateUrl if you want to publish a ClickOnce application that updates itself from a separate location from which it is installed.
我创建了一个特殊的 MSBuild 文件来做这些事情。它运行发布目标并将文件复制到正确的位置。
alhambraeidos 要求的构建文件示例。它基本上运行常规的 VisualStudio-build,然后将单击一次数据复制到真正的发布文件夹。请注意,删除了一些特定于项目的内容,因此它可能已损坏。此外,它不会增加内部版本号。这是由我们的 Continues-Build-Server 完成的:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Publish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- the folder of the project to build -->
<ProjLocation>..\YourProjectFolder</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Release</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<!-- This is the web-folder, which provides the artefacts for click-once. After this
build the project is actually deployed on the server -->
<DeploymentFolder>D:\server\releases\</DeploymentFolder>
</PropertyGroup>
<Target Name="Publish" DependsOnTargets="Clean">
<Message Text="Publish-Build started for build no $(ApplicationRevision)" />
<MSBuild Projects="$(ProjLocation)/YourProject.csproj" Properties="Configuration=Release" Targets="Publish"/>
<ItemGroup>
<SchoolPlannerSetupFiles Include="$(ProjPublishLocation)\*.*"/>
<SchoolPlannerUpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy
SourceFiles="@(SchoolPlannerSetupFiles)"
DestinationFolder="$(DeploymentFolder)\"
/>
<Copy
SourceFiles="@(SchoolPlannerUpdateFiles)"
DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"
/>
<CallTarget Targets="RestoreLog"/>
</Target>
<Target Name="Clean">
<Message Text="Clean project:" />
<MSBuild Projects="$(ProjLocation)/YourProject.csproj" Properties="Configuration=Release" Targets="Clean"/>
</Target>
</Project>
关于MSBuild 不尊重我的 ClickOnce 应用程序的 PublishUrl 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1919625/