如何获取TFS构建以使用已保存的发布配置文件预编译Web应用程序? [英] How do I get a TFS build to precompile a web application using a saved publish profile?

查看:457
本文介绍了如何获取TFS构建以使用已保存的发布配置文件预编译Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用TFS 2013进行CI构建和部署,以便部署,但是我需要预部署要部署的Web应用程序(WebForms)。我想使用发布配置文件来驱动预编译,然后将输出复制到放置位置,但我还没有找到任何能够做到这一点。



找到如何我配置MSBuild为WebDeploy使用保存的publishProfile?,我在我的Web应用程序中设置发布配置文件,如果我使用VS2013的开发人员命令提示符使用msbuild.exe

  msbuild.exe WebSite.csproj / p:DeployOnBuild = true / p:PublishProfile = TfsPrecompile 
pre>

发布名为TfsPrecompile的配置文件,并从 http:// stackoverflow .com / a / 13267694/595473

 <?xml version =1.0encoding =utf- 8→> 
< Project ToolsVersion =4.0xmlns =http://schemas.microsoft.com/developer/msbuild/2003>
< PropertyGroup>
< WebPublishMethod> FileSystem< / WebPublishMethod>
< LastUsedBuildConfiguration> Debug< / LastUsedBuildConfiguration>
< LastUsedPlatform>任何CPU< / LastUsedPlatform>
< SiteUrlToLaunchAfterPublish />
< ExcludeApp_Data> False< / ExcludeApp_Data>
< PublishUrl> $(MSBuildProjectDirectory)\PublishDirectory< / PublishUrl>
< DeleteExistingFiles> True< / DeleteExistingFiles>
< PrecompileBeforePublish> True< / PrecompileBeforePublish>
< EnableUpdateable> False< / EnableUpdateable>
< DebugSymbols> False< / DebugSymbols>
< WDPMergeOption> DonotMerge< / WDPMergeOption>
< / PropertyGroup>
< / Project>

在本地运行MSBuild,我最终得到一个新的 PublishDirectory


$ b $ p

要链接TFS和发布管理,我使用的是ReleaseTfvcTemplate.12.xaml模板。



Build> Projects: $ / Insert_Directory_Here / WebSite.csproj



高级> MSBuild参数: / p:DeployOnBuild = true / p:PublishProfile = TfsPrecompile



我使用MSBuild参数运行构建,与没有预编译参数的构建相比,在九分钟构建中没有显着的时间差异。当我在本地运行MSBuild时,我看到引用ASPNETCOMPILER滚动,虽然我没有看到任何TFS诊断日志中ASPNETCOMPILER或aspnet_compiler的引用。

解决方案

原来,构建框没有为执行发布所需的所有目标,所以它只是忽略它。



答案从 https://social.msdn.microsoft.com/Forums/vstudio/en-US/c2d10c74-ed44-4635-acb9-ab08612701e2/deployonbuild-not-working?forum=tfsbuild


最后!我有解决方案。无论是从Team Build部署还是直接使用MSBuild,您都需要将MSBuild目标复制到构建机器上,以便发布成功。



我们不安装Visual Studio到我们的构建机器上(浪费许可证) - 但是我们安装了Visual Studio Shell。似乎shell安装了一些MSBuild目标 - 但不是所有 - 并且当然不是发布。



因此,在一个安装VS的机器上去C:\Program文件(x86)\MSBuild \Microsoft



将整个文件夹复制到构建机器并替换相同的文件夹。也许可以备份原来的第一。



这对我来说是固定的!



I'm currently running a CI build and deploy using TFS 2013 for the build and Release Management 2013 for the deployment, though I need the web applications (WebForms) that I'm deploying to be precompiled. I'm looking to use a publish profile to drive the precompilation before the output is copied to the drop location, but I haven't found anything that has been able to do this yet.

After finding How do I configure MSBuild to use a saved publishProfile for WebDeploy? , I set up a publish profile in my web application that will precompile the web application if I use msbuild.exe using the Developer Command Prompt for VS2013

msbuild.exe WebSite.csproj /p:DeployOnBuild=true /p:PublishProfile=TfsPrecompile

Publish Profile named TfsPrecompile, with some help from http://stackoverflow.com/a/13267694/595473

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <PublishUrl>$(MSBuildProjectDirectory)\PublishDirectory</PublishUrl>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <PrecompileBeforePublish>True</PrecompileBeforePublish>
        <EnableUpdateable>False</EnableUpdateable>
        <DebugSymbols>False</DebugSymbols>
        <WDPMergeOption>DonotMerge</WDPMergeOption>
    </PropertyGroup>
</Project>

Running MSBuild locally, I end up with the precompiled site in a new PublishDirectory folder and all seems to have gone well.

To link TFS and Release Management, I'm using the ReleaseTfvcTemplate.12.xaml template.

Build > Projects: $/Insert_Directory_Here/WebSite.csproj

Advanced > MSBuild arguments: /p:DeployOnBuild=true /p:PublishProfile=TfsPrecompile

When I run the build with the MSBuild arguments there are no significant time differences in the nine-or-so minute build when compared to a build without the precompile arguments. When I run MSBuild locally I see references to ASPNETCOMPILER scroll by, though I see no references to ASPNETCOMPILER or aspnet_compiler in any of the TFS diagnostics logs.

解决方案

It turned out that the build box didn't have all the targets it needed in order to perform the publish, so it just ignored it.

Answer From https://social.msdn.microsoft.com/Forums/vstudio/en-US/c2d10c74-ed44-4635-acb9-ab08612701e2/deployonbuild-not-working?forum=tfsbuild

Finally! I have the solution. Whether deploying from Team Build or you are using MSBuild directly you will need to copy the MSBuild targets onto your build machine in order for publishing to succeed.

We do not install Visual Studio onto our build machine (waste of a license) - however we do install the Visual Studio Shell. It seems the shell installs some of the MSBuild targets - but not all - and certainly not Publishing.

Therefore on a machine with VS installed go to C:\Program Files (x86)\MSBuild\Microsoft

Copy this entire folder to your build machine and replace the same folder there. Maybe back up the original first. You could also probably figure out exactly which targets you actually need...

This fixed it for me!

这篇关于如何获取TFS构建以使用已保存的发布配置文件预编译Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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