54

I have created an ASP.NET Core Web API app using Visual Studio 2017 (Community Edition). I could successfully publish to an Azure App Service using Visual Studio.

I now want to set up CI/CD using VSTS. I used the 'Configure Continuous Delivery' option from Visual Studio which created a project in VSTS and created a build definition. I had to create a new build definition based on the 'ASP.NET Core' template in VSTS in order to avoid Nuget restore errors. The solution now builds and the tests are run but the 'Publish' task completes with a warning-

##[warning]No web project was found in the repository. Web projects are identified by the presence of either a web.config file or wwwroot folder in the directory.

The 'Publish Artifact' task has a similar warning -

##[warning]Directory 'd:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.

And obviously, the build does not produce any artifacts.

Do I need to add any build tasks to the default ASP.NET Core build template? How can I publish my Web API to Azure using VSTS?

Iman Bahrampour
  • 4,608
  • 2
  • 32
  • 57
alwayslearning
  • 4,253
  • 5
  • 32
  • 43

2 Answers2

90

As the warning message, your repository seems has no web project. So you should deselect the Publish Web Projects option in .NET Core publish task, and specify your .csproj in project(s) option.

enter image description here

And you can also find the hint message for Publish Web Projects option as below:

If true, the task will try to find the web projects in the repository and run the publish command on them. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory.

Marina Liu
  • 32,805
  • 4
  • 48
  • 60
  • 14
    I have this error, dotnet core 2. I don't have a web.config (instead I have a appsettings.json file), and found I could work around it by ensuring the wwwroot folder was in source control. In this case, in GitHub, I had to create a blank file in wwwroot for GitHub to pick up the folder (because for some reason GitHub doesn't like blank folders). – Sam Nov 20 '17 at 22:16
  • I have two builds that are nearly identical, both are API projects and both have no web.config files. But in one of the API projects, it just wouldn't create the zipped artefact until I applied this suggestion!?!? – reckface Jan 23 '18 at 22:06
  • Worked: step Publish -> Projects: **/*.csproj – Jorge Goncalves Feb 09 '18 at 17:09
  • 5
    **/*ProjectName.csproj should work when you specify the project name, and don't want to bother with the path – NMrt Feb 12 '18 at 05:56
  • use double asterics before .csproj, SO removes them – Tsagana Nokhaeva May 09 '18 at 19:09
2

This may help you..

I also faced this error according to my case i use wwwroot folder for save my files

project.csproj

  <ItemGroup>
    <Folder Include="wwwroot\FoodItem\" />
    <Folder Include="wwwroot\Shops\" />
  </ItemGroup>

after i push in to the vsts there were no wwwroot folder in side repo. because of that i got this error then again i pushed wwwroot with sub folders error fixed

Dulanga Heshan
  • 1,098
  • 12
  • 22