问题描述
我有一个C#.NET 4.0的项目与VS2010创建,现在正在使用VS2012访问。
I have a c# .Net 4.0 project created with VS2010 and now being accessed with VS2012.
我想从本网站只发布所需的文件一个目标位置的(C:\builds\MyProject [文件])
I'm trying to publish only the needed files from this website to a destination location (C:\builds\MyProject[Files])
我的文件结构:
./ProjectRoot/MyProject.csproj
./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
My file structure:./ProjectRoot/MyProject.csproj./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
我正在通过以下MSBuild的:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ./ProjectRoot/MyProject。的csproj / p:DeployOnBuild = TRUE / p:PublishProfile = / ProjectRoot /属性/ PublishProfiles / FileSystemDebug.pubxml
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.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:\builds\MyProject\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
由此产生的行为是:
The resulting behavior is:
- 在这里创建了一个zip文件: ./ ProjectRoot / OBJ /调试/封装/ MyProject.zip
- 没有被部署到
< publishUrl> C:\builds\MyProject\< / publishUrl>
WTF - 的所创建的zip文件是一个猪的早餐和充分的不需要的应用程序文件。
- a zip file is created here:./ProjectRoot/obj/Debug/Package/MyProject.zip
- Nothing is deployed to
<publishUrl>C:\builds\MyProject\</publishUrl>
WTF - the zip file that is created is a pigs breakfast and full of files that aren't needed for the application.
当我运行此发布个人资料通过Visual Studio在创建文件夹*的 C:\builds\MyProject * 的,包含我想要的确切文物
When I run this publish profile through visual studio a folder is created at *C:\builds\MyProject* and contains the exact artifacts that I want.
我如何获得的MSBuild这个简单的结果。
How do I get this simple result from msbuild?
推荐答案
FYI:我曾与Visual Studio 2015年同样的问题后的manies DeployOnBuild = TRUE / p::PublishProfile =我的资料
FYI: I had the same issue with Visual Studio 2015. After manies of hours of 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)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"
Condition="false" />
我改变了这一行,如下所示:
I changed this line as follows:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.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.)
这篇关于使用的MSBuild执行文件系统发布配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!