久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 msbuild 發(fā)布網(wǎng)頁?

How to Publish Web with msbuild?(如何使用 msbuild 發(fā)布網(wǎng)頁?)
本文介紹了如何使用 msbuild 發(fā)布網(wǎng)頁?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

Visual Studio 2010 有一個發(fā)布命令,允許您將 Web 應(yīng)用程序項(xiàng)目發(fā)布到文件系統(tǒng)位置.我想在我的 TeamCity 構(gòu)建服務(wù)器上執(zhí)行此操作,因此我需要使用解決方案運(yùn)行程序或 msbuild 執(zhí)行此操作.我嘗試使用 Publish 目標(biāo),但我認(rèn)為這可能適用于 ClickOnce:

msbuild Project.csproj/t:Publish/p:Configuration=Deploy

我基本上想做一個 Web 部署項(xiàng)目所做的事情,但沒有插件.我需要它來編譯 WAP,刪除任何不需要執(zhí)行的文件,執(zhí)行任何 web.xml 文件.配置轉(zhuǎn)換,并將輸出復(fù)制到指定位置.

我的解決方案,基于 Jeff Siver 的回答

<Target Name="Deploy"><MSBuild Projects="$(SolutionFile)"屬性="配置=$(配置);DeployOnBuild=true;DeployTarget=Package"ContinueOnError="假"/><Exec Command="&quot;$(ProjectPath)obj$(Configuration)Package$(ProjectName).deploy.cmd&quot;/y/m:$(DeployServer) -enableRule:DoNotDeleteRule"ContinueOnError="假"/></目標(biāo)>

解決方案

我得到它主要是在沒有自定義 msbuild 腳本的情況下工作.以下是相關(guān)的 TeamCity 構(gòu)建配置設(shè)置:

<上一頁>工件路徑:%system.teamcity.build.workingDir%MyProjectobjDebugPackagePackageTmp運(yùn)行器類型:MSBuild(用于 MSBuild 文件的運(yùn)行器)構(gòu)建文件路徑:MyProjectMyProject.csproj工作目錄:與結(jié)帳目錄相同MSBuild 版本:Microsoft .NET Framework 4.0MSBuild 工具版本:4.0運(yùn)行平臺:x86目標(biāo):包MSBuild.exe 的命令行參數(shù):/p:Configuration=Debug

這將編譯、打包(使用 web.config 轉(zhuǎn)換)并將輸出保存為工件.唯一缺少的是將輸出復(fù)制到指定位置,但這可以在另一個帶有工件依賴項(xiàng)的 TeamCity 構(gòu)建配置或使用 msbuild 腳本中完成.

更新

這是一個 msbuild 腳本,它將編譯、打包(使用 web.config 轉(zhuǎn)換)并將輸出復(fù)制到我的登臺服務(wù)器

<?xml version="1.0" encoding="utf-8" ?><Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><屬性組><配置條件="'$(Configuration)' == ''">發(fā)布</配置><解決方案名稱>我的解決方案</解決方案名稱><SolutionFile>$(SolutionName).sln</SolutionFile><項(xiàng)目名稱>我的項(xiàng)目</項(xiàng)目名稱><ProjectFile>$(ProjectName)$(ProjectName).csproj</ProjectFile></屬性組><目標(biāo)名稱="Build" DependsOnTargets="BuildPackage;CopyOutput"/><目標(biāo)名稱="BuildPackage"><MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(Configuration)"/><MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(Configuration)"/></目標(biāo)><目標(biāo)名稱="復(fù)制輸出"><項(xiàng)目組><PackagedFiles Include="$(ProjectName)obj$(Configuration)PackagePackageTmp***.*"/></項(xiàng)目組><Copy SourceFiles="@(PackagedFiles)" DestinationFiles="@(PackagedFiles->'\build02wwwroot$(ProjectName)$(Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/></目標(biāo)></項(xiàng)目>

您還可以從 PropertyGroup 標(biāo)記中刪除 SolutionName 和 ProjectName 屬性并將它們傳遞給 msbuild.

msbuild build.xml/p:Configuration=Deploy;SolutionName=MySolution;ProjectName=MyProject

更新 2

由于這個問題仍然有大量流量,我認(rèn)為值得用我當(dāng)前使用 Web 部署(也稱為 MSDeploy).

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0"><屬性組><配置條件="'$(Configuration)' == ''">發(fā)布</配置><ProjectFile Condition="'$(ProjectFile)' == ''">$(ProjectName)$(ProjectName).csproj</ProjectFile><DeployServiceUrl 條件="'$(DeployServiceUrl)' == ''">http://staging-server/MSDeployAgentService</DeployServiceUrl></屬性組><目標(biāo)名稱="驗(yàn)證屬性"><!-- 驗(yàn)證我們是否具有所有必需屬性的值--><錯誤條件="'$(ProjectName)' == '' " Text="ProjectName 是必需的."/></目標(biāo)><目標(biāo)名稱="構(gòu)建" DependsOnTargets="VerifyProperties"><!-- 使用windows身份驗(yàn)證部署--><MSBuild Projects="$(ProjectFile)"屬性=配置=$(配置);MvcBuildViews=假;部署構(gòu)建=真;部署目標(biāo)=MSDeployPublish;CreatePackageOnPublish=真;AllowUntrustedCertificate=True;MSDeployPublishMethod=遠(yuǎn)程代理;MsDeployServiceUrl=$(DeployServiceUrl);SkipExtraFilesOnServer=真;用戶名=;密碼=;"ContinueOnError="假"/></目標(biāo)></項(xiàng)目>

在 TeamCity 中,我有名為 env.Configurationenv.ProjectNameenv.DeployServiceUrl 的參數(shù).MSBuild 運(yùn)行器具有構(gòu)建文件路徑,并且參數(shù)自動傳遞(您不必在命令行參數(shù)中指定它們).

你也可以從命令行運(yùn)行它:

msbuild build.xml/p:Configuration=Staging;ProjectName=MyProject;DeployServiceUrl=http://staging-server/MSDeployAgentService

Visual Studio 2010 has a Publish command that allows you to publish your Web Application Project to a file system location. I'd like to do this on my TeamCity build server, so I need to do it with the solution runner or msbuild. I tried using the Publish target, but I think that might be for ClickOnce:

msbuild Project.csproj /t:Publish /p:Configuration=Deploy

I basically want to do exactly what a web deployment project does, but without the add-in. I need it to compile the WAP, remove any files unnecessary for execution, perform any web.config transformations, and copy the output to a specified location.

My Solution, based on Jeff Siver's answer

<Target Name="Deploy">
    <MSBuild Projects="$(SolutionFile)" 
             Properties="Configuration=$(Configuration);DeployOnBuild=true;DeployTarget=Package" 
             ContinueOnError="false" />
    <Exec Command="&quot;$(ProjectPath)obj$(Configuration)Package$(ProjectName).deploy.cmd&quot; /y /m:$(DeployServer) -enableRule:DoNotDeleteRule" 
          ContinueOnError="false" />
</Target>

解決方案

I got it mostly working without a custom msbuild script. Here are the relevant TeamCity build configuration settings:

Artifact paths: %system.teamcity.build.workingDir%MyProjectobjDebugPackagePackageTmp 
Type of runner: MSBuild (Runner for MSBuild files) 
Build file path: MyProjectMyProject.csproj 
Working directory: same as checkout directory 
MSBuild version: Microsoft .NET Framework 4.0 
MSBuild ToolsVersion: 4.0 
Run platform: x86 
Targets: Package 
Command line parameters to MSBuild.exe: /p:Configuration=Debug

This will compile, package (with web.config transformation), and save the output as artifacts. The only thing missing is copying the output to a specified location, but that could be done either in another TeamCity build configuration with an artifact dependency or with an msbuild script.

Update

Here is an msbuild script that will compile, package (with web.config transformation), and copy the output to my staging server

<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
        <SolutionName>MySolution</SolutionName>
        <SolutionFile>$(SolutionName).sln</SolutionFile>
        <ProjectName>MyProject</ProjectName>
        <ProjectFile>$(ProjectName)$(ProjectName).csproj</ProjectFile>
    </PropertyGroup>

    <Target Name="Build" DependsOnTargets="BuildPackage;CopyOutput" />

    <Target Name="BuildPackage">
        <MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(Configuration)" />
        <MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(Configuration)" />
    </Target>

    <Target Name="CopyOutput">
        <ItemGroup>
            <PackagedFiles Include="$(ProjectName)obj$(Configuration)PackagePackageTmp***.*"/>
        </ItemGroup>
        <Copy SourceFiles="@(PackagedFiles)" DestinationFiles="@(PackagedFiles->'\build02wwwroot$(ProjectName)$(Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/>
    </Target>
</Project>

You can also remove the SolutionName and ProjectName properties from the PropertyGroup tag and pass them to msbuild.

msbuild build.xml /p:Configuration=Deploy;SolutionName=MySolution;ProjectName=MyProject

Update 2

Since this question still gets a good deal of traffic, I thought it was worth updating my answer with my current script that uses Web Deploy (also known as MSDeploy).

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
    <ProjectFile Condition=" '$(ProjectFile)' == '' ">$(ProjectName)$(ProjectName).csproj</ProjectFile>
    <DeployServiceUrl Condition=" '$(DeployServiceUrl)' == '' ">http://staging-server/MSDeployAgentService</DeployServiceUrl>
  </PropertyGroup>

  <Target Name="VerifyProperties">
    <!-- Verify that we have values for all required properties -->
    <Error Condition=" '$(ProjectName)' == '' " Text="ProjectName is required." />
  </Target>

  <Target Name="Build" DependsOnTargets="VerifyProperties">
    <!-- Deploy using windows authentication -->
    <MSBuild Projects="$(ProjectFile)"
             Properties="Configuration=$(Configuration);
                             MvcBuildViews=False;
                             DeployOnBuild=true;
                             DeployTarget=MSDeployPublish;
                             CreatePackageOnPublish=True;
                             AllowUntrustedCertificate=True;
                             MSDeployPublishMethod=RemoteAgent;
                             MsDeployServiceUrl=$(DeployServiceUrl);
                             SkipExtraFilesOnServer=True;
                             UserName=;
                             Password=;"
             ContinueOnError="false" />
  </Target>
</Project>

In TeamCity, I have parameters named env.Configuration, env.ProjectName and env.DeployServiceUrl. The MSBuild runner has the build file path and the parameters are passed automagically (you don't have to specify them in Command line parameters).

You can also run it from the command line:

msbuild build.xml /p:Configuration=Staging;ProjectName=MyProject;DeployServiceUrl=http://staging-server/MSDeployAgentService

這篇關(guān)于如何使用 msbuild 發(fā)布網(wǎng)頁?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒有辦法知道是否有人為您的網(wǎng)站添加了書簽?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點(diǎn)的“活動用戶數(shù))
Best way to keep track of current online users(跟蹤當(dāng)前在線用戶的最佳方式)
Publish one web project from solution with msbuild(使用 msbuild 從解決方案發(fā)布一個 Web 項(xiàng)目)
#39;dotnet restore#39; vs. #39;nuget restore#39; with TeamCity(使用 TeamCity 的“dotnet restore與“nuget restore)
Could not load file or assembly #39;Microsoft.Build.Framework#39;(VS 2017)(無法加載文件或程序集“Microsoft.Build.Framework(VS 2017))
主站蜘蛛池模板: 日韩精品免费 | 免费一级片 | 亚洲一区中文字幕 | 久久精品2| 天天操夜夜骑 | 精品少妇一区二区三区免费观 | 中文在线观看免费网站 | 三级黄色在线观看 | 深夜福利av | 一区二区三区视频在线播放 | 黄网站免费大全入口 | 日韩免费观看视频 | 国产www在线观看 | 97超碰资源 | 亚洲性色av | 天天爽夜夜爽夜夜爽精品视频 | 波多野结衣乳巨码无在线观看 | 免费日韩视频 | 91在线精品视频 | 欧美一级片免费 | 免费的av| 国产精品手机在线观看 | 色交视频| 天天干天天色天天射 | 日韩精品三区 | 亚洲美女一区 | 免费欧美视频 | 欧美日韩中文 | 成人免费视频国产免费麻豆 | 人人爽爽人人 | 男女激情av | 国产一级网站 | 91porn在线| 亚洲网站在线 | 视频一二区 | 成年视频在线观看 | 国产一区二区视频在线 | 亚洲在线中文字幕 | 男人天堂手机在线 | 天天操天天做 | 韩日精品视频 |