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 执行文件系统发布配置文件
基础教程推荐
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 将数据集转换为列表 2022-01-01
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 获取C#保存对话框的文件路径 2022-01-01
