Build one web project from a Solution with multipl

2019-04-06 06:38发布

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.

  • I have not found how to build only one project using a "Visual Studio Build" step.

It would be great if exist such a way to do this with "Visual Studio Build" step.

  • I also tried to use an "MSBuild" step. Unfortunately I got a problem when restoring the packages with Nuget. I got the error: ##[error]No file format header found, ##[error]Unexpected exit code 1 returned from tool NuGet.exe. Right after run: Nuget.exe restore Myproj.csproj.

Summarizing:

How can I build only one web project from a solution with multiple web projects in visual studio online build definition?

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.

enter image description here

Also

I found a comment from chrisrpatterson in a VSO issue: https://github.com/Microsoft/vso-agent-tasks/issues/571

Wich he says: You can't run nuget restore against anything other than an SLN file. You should uncheck restore nuget packages on that vsbuild task.

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?

3条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-04-06 06:56

You may want to create a solution with just the web project that you want to build.

In visual studio you can create a new project, and in that dialog select "other project types\solution".

The new solution can sit right next to the existing one..

查看更多
戒情不戒烟
3楼-- · 2019-04-06 06:58

Instead of choosing the .sln file, you need to select the .proj file.

Firstly, click the ellipsis button next to the Solution field. enter image description here

Then choose the .proj file you want to build. 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)enter image description here

查看更多
干净又极端
4楼-- · 2019-04-06 07:01

You can add a new "Azure App Service Deploy" task to your build definition and set the "Package or folder field" to "$(build.artifactstagingdirectory)**\YOURPROJECT.zip"

查看更多
登录 后发表回答