安装程序使用VSTS发布到文件夹 [英] Setup publish to folder using VSTS

本文介绍了安装程序使用VSTS发布到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中通过右键单击项目->发布->发布到文件夹来使用publish to folder选项.结果始终是具有应用转换的易于复制的项目. 我想使用VSTS自动化此过程,并在VSTS上建立设置.
我使用了以下步骤:
-NuGet restore
-Build solution
-Publish Build Artifacts$(build.artifactstagingdirectory)
-使用admin loginpassword

I was using publish to folder option through Visual Studio by right-clicking on the project -> publish -> publish to folder. Result was always ready-to-copy project with applied transformations. I wanted to automate this process using VSTS and have setup build on VSTS.
I used next steps:
- NuGet restore
- Build solution
- Publish Build Artifacts to $(build.artifactstagingdirectory)
- Windows machine file copy from $(build.artifactstagingdirectory) to remote machine using admin login and password

最后,我在具有复杂文件夹结构的远程计算机上获得了zip软件包,根本没有在其中进行任何转换.
怎么了?如何使用VSTS设置与Visual Studio中相同的发布到文件夹"?

And finally I'm getting zip package on remote machine with complicated folder structure without applied transformations inside at all.
What is wrong? How I can setup same "publish to folder" as in Visual Studio but using VSTS?

推荐答案

在目标下方添加到.csproj以启用转换配置文件

Add below Target to your .csproj to enable transforming config files

<Target Name="TransformConfigFiles" AfterTargets="AfterBuild" Condition="'$(TransformConfigFiles)'=='true'">
<ItemGroup>
  <DeleteAfterBuild Include="$(WebProjectOutputDir)\Web.*.config" />
</ItemGroup>
<TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\Web.config" />
<Delete Files="@(DeleteAfterBuild)" /></Target>

在构建解决方案步骤中,添加以下构建参数"/p:TransformConfigFiles = true"将使用上述添加的目标对.csproj进行配置转换

In your build solution step add the following build arguments "/p:TransformConfigFiles=true" will make the config transformation using the above added target to .csproj

/p:TransformConfigFiles=true /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:OutDir="$(build.stagingDirectory)"

然后,您可以使用发布步骤来发布$(build.stagingDirectory)内容.如果只需要网站输出,则可以使用$(build.stagingDirectory)_PublishedWebsites作为发布路径.

Then you can use a publish step to publish your $(build.stagingDirectory) contents. You can use $(build.stagingDirectory)_PublishedWebsites as path to publish if you only need the website output.

这将允许您获取ms部署软件包以及xcopy部署已发布的网站文件.

This will allow you to get the ms deploy package as well as xcopy deploy published website files.

如果在$(build.stagingDirectory)中有其他文件,则可以在发布任务之前使用复制文件任务来复制任何其他文件,并将它们作为构建工件发布.

You can use copy files task before the publish task to copy any additional files if you have any to $(build.stagingDirectory) and get them published as build artifacts.

使用带有 >部署组,将您的应用程序部署到目标服务器.您可以使用 IIS部署任务来使用ms部署到IIS部署程序包.如果您使用的是Web部署程序包,则可以使用 parameters.xml ,以获取分配给.setparameters.xml的网络配置参数,以便您可以在IIS部署任务完成部署时间.

Use VSTS release management with deployment groups to deploy your application to target server. You can use IIS deploy task to deploy to IIS using ms deploy package. If you are using web deploy package you can use a parameters.xml in your web app to get the web config parameters assigned to .setparameters.xml so that you can change values in the deployment time using IIS deployment task.

这篇关于安装程序使用VSTS发布到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆