問題描述
我有一個用 VS2010 創(chuàng)建的 c# .Net 4.0 項(xiàng)目,現(xiàn)在可以用 VS2012 訪問.
I have a c# .Net 4.0 project created with VS2010 and now being accessed with VS2012.
我正在嘗試僅將所需文件從該網(wǎng)站發(fā)布到目標(biāo)位置(C:uildsMyProject[Files])
I'm trying to publish only the needed files from this website to a destination location (C:uildsMyProject[Files])
我的文件結(jié)構(gòu):./ProjectRoot/MyProject.csproj./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
My file structure: ./ProjectRoot/MyProject.csproj ./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
我正在通過 MSBuild 運(yùn)行以下命令:
C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe ./ProjectRoot/MyProject.csproj/p:DeployOnBuild=true/p:PublishProfile=./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe ./ProjectRoot/MyProject.csproj /p:DeployOnBuild=true /p:PublishProfile=./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
這是 FileSystemDebug.pubxml 中的 xml
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:uildsMyProject</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
產(chǎn)生的行為是:
- 在此處創(chuàng)建一個 zip 文件:./ProjectRoot/obj/Debug/Package/MyProject.zip
- 沒有部署到
<publishUrl>C:uildsMyProject</publishUrl>
WTF - 創(chuàng)建的 zip 文件是豬的早餐,其中包含應(yīng)用程序不需要的文件.
當(dāng)我通過 Visual Studio 運(yùn)行此發(fā)布配置文件時,會在 *C:uildsMyProject* 處創(chuàng)建一個文件夾,其中包含我想要的確切工件.
When I run this publish profile through visual studio a folder is created at *C:uildsMyProject* and contains the exact artifacts that I want.
如何從 msbuild 獲得這個簡單的結(jié)果?
How do I get this simple result from msbuild?
推薦答案
僅供參考:我在使用 Visual Studio 2015 時遇到了同樣的問題.經(jīng)過數(shù)小時的嘗試,我現(xiàn)在可以執(zhí)行 msbuild myproject.csproj/p:DeployOnBuild=true/p:PublishProfile=myprofile
.
FYI: I had the same issue with Visual Studio 2015. After many of hours trying, I can now do msbuild myproject.csproj /p:DeployOnBuild=true /p:PublishProfile=myprofile
.
我必須編輯我的 .csproj 文件才能使其正常工作.它包含這樣的一行:
I had to edit my .csproj file to get it working. It contained a line like this:
<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets"
Condition="false" />
我把這一行改成如下:
<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov14.0WebApplicationsMicrosoft.WebApplication.targets" />
(我把10.0改成了14.0,不知道有沒有必要,但肯定要去掉條件部分.)
(I changed 10.0 to 14.0, not sure whether this was necessary. But I definitely had to remove the condition part.)
這篇關(guān)于使用 msbuild 執(zhí)行文件系統(tǒng)發(fā)布配置文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!