我有一个用 VS2010 创建的 c# .Net 4.0 项目,现在可以用 VS2012 访问.
I have a c# .Net 4.0 project created with VS2010 and now being accessed with VS2012.
我正在尝试仅将所需文件从该网站发布到目标位置(C:uildsMyProject[Files])
I'm trying to publish only the needed files from this website to a destination location (C:uildsMyProject[Files])
我的文件结构:./ProjectRoot/MyProject.csproj./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
My file structure: ./ProjectRoot/MyProject.csproj ./ProjectRoot/Properties/PublishProfiles/FileSystemDebug.pubxml
我正在通过 MSBuild 运行以下命令:
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>
产生的行为是:
<publishUrl>C:uildsMyProject</publishUrl>
WTF当我通过 Visual Studio 运行此发布配置文件时,会在 *C:uildsMyProject* 处创建一个文件夹,其中包含我想要的确切工件.
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 获得这个简单的结果?
How do I get this simple result from msbuild?
仅供参考:我在使用 Visual Studio 2015 时遇到了同样的问题.经过数小时的尝试,我现在可以执行 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.)
这篇关于使用 msbuild 执行文件系统发布配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!