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

如何使用 msbuild 發布網頁?

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

問題描述

Visual Studio 2010 有一個發布命令,允許您將 Web 應用程序項目發布到文件系統位置.我想在我的 TeamCity 構建服務器上執行此操作,因此我需要使用解決方案運行程序或 msbuild 執行此操作.我嘗試使用 Publish 目標,但我認為這可能適用于 ClickOnce:

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

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

我的解決方案,基于 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="假"/></目標>

解決方案

我得到它主要是在沒有自定義 msbuild 腳本的情況下工作.以下是相關的 TeamCity 構建配置設置:

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

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

更新

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

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

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

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

更新 2

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

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

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

你也可以從命令行運行它:

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

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

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

相關文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒有辦法知道是否有人為您的網站添加了書簽?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點的“活動用戶數)
Best way to keep track of current online users(跟蹤當前在線用戶的最佳方式)
Publish one web project from solution with msbuild(使用 msbuild 從解決方案發布一個 Web 項目)
#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))
主站蜘蛛池模板: 91综合网| 天天色综 | 亚洲国产视频一区 | 日韩精品一区二区三区在线 | 久久中文字幕一区 | 欧美极品在线观看 | 天天碰日日操 | 成人毛片在线视频 | 免费视频二区 | 成人精品 | 亚洲a在线观看 | 亚洲成人精品国产 | 天天躁人人躁人人躁狂躁 | 国产69精品久久久久777 | 欧美激情一区二区三区 | ww 255hh 在线观看 | 亚洲精品久久久久中文字幕欢迎你 | 亚洲不卡在线观看 | 一区二区三区国产好 | 91国产精品 | 久久久久久久久精 | 91久久久久久久久久久 | 天天精品在线 | 国产色在线 | 精品国产一区二区 | 亚州激情| 成人精品视频99在线观看免费 | 不卡一区二区三区四区 | 草草影院ccyy | 欧美国产日韩一区 | 精品国产一区二区国模嫣然 | 人人操日日干 | 请别相信他免费喜剧电影在线观看 | 国产美女在线看 | 精品久久久久久 | 欧美一区二区三区国产精品 | 天天综合网天天综合 | 一级做a毛片 | 国产精品特级片 | 91亚洲国产成人久久精品网站 | 超碰电影 |