Using msbuild to execute a File System Publish Profile(使用 msbuild 执行文件系统发布配置文件)
问题描述
我有一个用 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>
产生的行为是:
- 在此处创建一个 zip 文件:./ProjectRoot/obj/Debug/Package/MyProject.zip
- 没有部署到
<publishUrl>C:uildsMyProject</publishUrl>
WTF - 创建的 zip 文件是猪的早餐,其中包含应用程序不需要的文件.
当我通过 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 执行文件系统发布配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 msbuild 执行文件系统发布配置文件


- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01