Building Project in VSTS doesn't build all pro

2019-04-01 04:32发布

I'm having a strange issue where when I create a build with "Visual Studio Build" and supply the *.sln file it pretends to build all projects (I see this in the log) but when it comes to publishing artifacts there is only a few of the projects from the solution (mainly test projects and some miscellaneous projects but no the main ones) I have dependencies sorted ok as this build fine in VS2015 (I currently use WebDeploy) Has anyone seen this behavior?

2条回答
贼婆χ
2楼-- · 2019-04-01 05:19

I also had this issue (or similar?) The artifacts for the main project were not published, only the test project.

When looking in the log file i noticed two things.

  1. Only files from the Test project were copied

  2. The task "Copy Files to:$(build.artifactstagingdirectory)" was looking for contents using the wildcard "\bin\release**" this path is set in the build step "Copy Files" / "Content" and is "\bin\$(BuildConfiguration)**" by default, translating to your setting in "Variables" / "BuildConfiguration" under this build definition.

Then I looked at the project settings in Visual Studio and for some reason the main project had the setting in "Build / Output / Output path" set to "bin\"; changing this to "bin\Release" for Release and "bin\Debug" for debug solved my problem.

Solution?

a. Set VS project setting "Build / Output / Output path" to "bin\Release"

b. (or change VSTS build step "Copy Files" / "Content" to "\bin" to catch everything in bin)

查看更多
够拽才男人
3楼-- · 2019-04-01 05:33

Since you mentioned "WebDeploy", I suspect that you are building a web app project with some other projects in the solution. The behavior you see is usually caused by the default "Visual Studio" build definition template. With the default settings of this template, the "Copy Files" task copy the files in "**\bin\$(BuildConfiguration)**" folder to "$(build.artifactstagingdirectory)" folder and then publish the files in "$(build.artifactstagingdirectory)" folder. But this is not applicable to Web App Project.

To fix this issue, adding following arguments in "MSBuild Arguments" section of "Visual Studio Build" task:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"

Then you will get a deployment package in artifacts and you can deploy it via web deploy.

查看更多
登录 后发表回答