2013-10-10 37 views
10

當嘗試部署使用的TeamCity和Web部署我的網站我得到這個錯誤:MsDeployPublish位於何處?

error MSB4057: The target "MsDeployPublish" does not exist in the project. 

有什麼我必須安裝一個構建服務器上?這是一個乾淨的Windows Server 2012,安裝了Web Deploy 3.5。

回答

5

我意識到這個問題是很老在這一點上,而是:

MsDeployPublish安裝有Web應用程序的目標是Visual Studio中的一部分。如果您只安裝了Server + Web Deploy,則需要從開發人員安裝中複製它們或安裝Visual Studio。目標可以從%programfiles(x86)%\MSBuild\Microsoft\VisualStudio

順便說一句,在Visual Studio 2012發佈後添加了一些功能,即與發佈配置文件(.pubxml)相關的功能。這些可以通過安裝在Azure SDK加入到VS2010和將被安裝到%programfiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.5\Web

+0

這解決了我的問題。我只在我的工作站上安裝了WebDeploy的服務器版本。我需要安裝完整版本的WebDeploy才能正確構建。 – dthrasher

16

或者你可以用這個NuGet包與目標攜帶版:https://www.nuget.org/packages/MSBuild.Microsoft.VisualStudio.Web.targets和修改您的csproj文件,包括像這樣:

<Import Project="..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.12.0.1\tools\VSToolsPath\WebApplications\Microsoft.WebApplication.targets" /> 
+1

如果您不想安裝Visual Studio,這是TeamCity在構建服務器上的最佳答案。有幾點需要注意 - 確保路徑引用與您安裝的Web.targets的版本相匹配,並確保上面的Import行替換了Microsoft.WebApplication.targets的任何其他導入引用(它們可能會在Web中更進一步。配置文件),否則你會得到一個「'存在'功能只接受標量值」編譯錯誤。 – Raelshark

+0

@ Raelshark的評論:我不確定我是否幸運並且它們都匹配,但只需添加它爲我工作的nuget包。 nuget包含了14.0.0.3,在我的複製文件夾'C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v14 \'到代理服務器之前的其他一些步驟。這又與構建配置中的'ToolsVersion'匹配。 Teamcity及其文件... :( – CularBytes

4

這對我有用,我不得不添加行來導入Microsoft.WebApplication.targets 從一個很好的VS2013項目得到了。

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 
    <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> 
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />