【发布时间】:2017-05-24 12:18:40
【问题描述】:
我有一个相当大的多项目解决方案。我目前在 Visual Studio 中构建它,然后使用右键单击 => 发布选项进行发布。这很好用。
我现在处于需要将 clickonce 发布自动化的位置,这超出了我在 Visual Studio 中的能力。我已经成功创建了一个 publish.xml 文件,我可以将它与 msbuild 和 mage 一起使用来创建看起来像 clickonce 的东西。但是,我在 Visual Studio 界面中的配置非常复杂,我希望能够简单地将其复制到我的 publish.xml 文件中。
当 Visual Studio 从右键单击 => 发布过程发布时,是否可以让 Visual Studio 生成一个提供 MSBuild 和/或 Mage 使用的属性的文件?
基本上,我想要一个配置文件,我可以使用它来执行类似 msbuild publish.xml(或类似)的操作,并准确获取 Visual Studio 制作的发布结果。
我目前使用的是 VS2017。该应用程序是使用c#的winforms
这是我的 publish.xml。它不应该是超出测试的任何东西
<Project>
<PropertyGroup>
<OutputPathBuild>C:\Users\d_000\Documents\Visual Studio 2017\Projects\CP\CP.UI.Winforms\bin\x86\Debug</OutputPathBuild>
<Version>1.0.0.0</Version>
<OutputPathDeployment>C:\Users\d_000\Documents\CP Deploy\test</OutputPathDeployment>
<Mage>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\mage.EXE</Mage>
</PropertyGroup>
<Target Name="Deployment">
<Error Condition="'$(Version)'==''" Text="The Version property must be defined in order to build the Deployment task."/>
<ItemGroup>
<DeploySource Include="$(OutputPathBuild)\**"/>
</ItemGroup>
<Copy SourceFiles="@(DeploySource)" DestinationFolder="$(OutputPathDeployment)\v$(Version)\%(RecursiveDir)"/>
<Exec Command='"$(Mage)" -New Application -ToFile "$(OutputPathDeployment)\v$(Version)\MyApp.manifest" -Name MyApp -Version $(Version) -Processor X86 -FromDirectory "$(OutputPathDeployment)\v$(Version)" -IconFile Resources\CPIcon.ico'/>
<Exec Command='"$(Mage)" -New Deployment -ToFile "$(OutputPathDeployment)\MyApp.application" -Name MyApp -Version $(Version) -Processor X86 -AppManifest "$(OutputPathDeployment)\v$(Version)\MyApp.manifest" -IncludeProviderURL true -ProviderURL "http://example.com/download/MyApp/MyApp.application" -Install true'/>
<!-- Grr... Mage tool has a bug whereby -MinVersion only works in Update mode... -->
<Exec Command='"$(Mage)" -Update "$(OutputPathDeployment)\MyApp.application" -MinVersion $(Version)'/>
<Copy SourceFiles="$(OutputPathDeployment)\MyApp.application" DestinationFiles="$(OutputPathDeployment)\MyApp.v$(Version).application"/>
</Target>
</Project>
编辑:
我需要自定义发布过程中的内容,因此我希望了解 Visual Studio 在做什么。本质上,我想让命令在 Visual Studio 中运行,复制它们并调整它们,这样我就可以使用不同的 delpoy URL 自动化几个不同的构建并更新 URL
【问题讨论】:
-
如果我正确理解了您的问题,您的
.pubxml文件夹中应该已经有一个.pubxml文件? -
否 - 似乎所有发布设置都包含在项目文件中
标签: c# visual-studio msbuild mage