简体   繁体   English

在 Visual Studio Online Build Definition 中从具有多个 Web 项目的解决方案构建一个 Web 项目

[英]Build one web project from a Solution with multiple web projects in Visual Studio Online Build Definition

I'm facing a problem where I need to build only one web project from a solution with two web projects in Visual Studio Online.我面临一个问题,我只需要从 Visual Studio Online 中包含两个 Web 项目的解决方案构建一个 Web 项目。

  • I have not found how to build only one project using a "Visual Studio Build" step.我还没有找到如何使用“Visual Studio Build”步骤仅构建一个项目。

It would be great if exist such a way to do this with "Visual Studio Build" step.如果存在这样一种使用“Visual Studio Build”步骤执行此操作的方法,那就太好了。

  • I also tried to use an "MSBuild" step.我还尝试使用“MSBuild”步骤。 Unfortunately I got a problem when restoring the packages with Nuget.不幸的是,我在使用 Nuget 恢复软件包时遇到了问题。 I got the error: ##[error]No file format header found, ##[error]Unexpected exit code 1 returned from tool NuGet.exe.我收到错误:##[error]No file format header found,##[error]从工具 NuGet.exe 返回意外退出代码 1。 Right after run: Nuget.exe restore Myproj.csproj .运行后立即: Nuget.exe 恢复 Myproj.csproj

Summarizing:总结:

How can I build only one web project from a solution with multiple web projects in visual studio online build definition?如何在 Visual Studio 在线构建定义中从具有多个 Web 项目的解决方案中仅构建一个 Web 项目?

Update更新

Here is an image of the error when I'm building.这是我构建时的错误图像。 Also i'm getting this using "Visual Studio Build" step or "MSBuild" step.此外,我使用“Visual Studio Build”步骤或“MSBuild”步骤来获取此信息。

在此处输入图片说明

Also

I found a comment from chrisrpatterson in a VSO issue: https://github.com/Microsoft/vso-agent-tasks/issues/571我在 VSO 问题中找到了 chrisrpatterson 的评论: https : //github.com/Microsoft/vso-agent-tasks/issues/571

Which he says: You can't run nuget restore against anything other than an SLN file.他说:你不能对 SLN 文件以外的任何东西运行 nuget restore。 You should uncheck restore nuget packages on that vsbuild task.您应该取消选中该 vsbuild 任务上的还原 nuget 包。

But I need the packages, and I don't want to push my packages folder into my repo.但是我需要这些包,而且我不想将我的包文件夹推送到我的仓库中。

So, how can I restore the packages and run only one web project from my solution in "Visual Studio Build" step?那么,如何在“Visual Studio Build”步骤中从我的解决方案中恢复包并仅运行一个 Web 项目?

Instead of choosing the .sln file, you need to select the .proj file.您需要选择 .proj 文件,而不是选择 .sln 文件。

Firstly, click the ellipsis button next to the Solution field.首先,单击“解决方案”字段旁边的省略号按钮。 在此处输入图片说明

Then choose the .proj file you want to build.然后选择要构建的 .proj 文件。 For example, the screenshot below shows that the build definition is configured to build the ClassLibrary1 project, instead of the whole solution (contains ClassLibrary1 and ClassLibrary4 project)例如,下面的截图显示构建定义被配置为构建 ClassLibrary1 项目,而不是整个解决方案(包含 ClassLibrary1 和 ClassLibrary4 项目) 在此处输入图片说明

您可以将新的“Azure 应用服务部署”任务添加到您的构建定义,并将“包或文件夹字段”设置为“$(build.artifactstagingdirectory)**\\YOURPROJECT.zip”

You may want to create a solution with just the web project that you want to build.您可能只想使用要构建的 Web 项目创建解决方案。

In visual studio you can create a new project, and in that dialog select "other project types\\solution".在 Visual Studio 中,您可以创建一个新项目,然后在该对话框中选择“其他项目类型\\解决方案”。

The new solution can sit right next to the existing one..新解决方案可以紧邻现有解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何构建和部署具有多个项目的Visual Studio解决方案 - How to build and deploy a visual studio solution with multiple projects Visual Studio Online Build - web.config连接字符串configSource - Visual Studio Online Build - web.config connection strings configSource 如何从Visual Studio中的项目解决方案中删除其他构建文件 - How to Delete Additional build files from the Project Solution in visual studio 如何在Visual Studio中构建和运行多个项目 - How to build and run multiple projects in Visual Studio 从具有多个项目的解决方案构建 docker 容器 - Build docker container from solution with multiple projects 解决方案中用于Web项目的TFS 2015“ vNext”构建 - TFS 2015 “vNext” Build for web project in solution Visual Studio解决方案:获取与构建配置相关的项目 - Visual Studio Solution: Get projects related to a build configuration Visual Studio 2010:如何在解决方案中强制执行项目的构建顺序? - Visual Studio 2010: How to enforce build order of projects in a solution? 使用C#和Powershell项目构建Visual Studio解决方案 - Build a Visual Studio Solution with C# AND Powershell projects 从代码构建visual studio解决方案 - Build visual studio solution from code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM