On Visual Studio Team Services, to quickly and easily build your ASP.Net Core applications, you can use the pre-built ASP.Net Core Template in the Build section of VSTS.

1. pre-built-asp-net-core-template

But when you try to use this ASP.Net Core Pre-Built template with a .csproj based .Net Core Application, you run in to an issue where the build will fail at restoring the NuGet dependencies with the error message,

 Invalid input ‘xxxxxxxxxx.csproj’. The file type was not recognized.

2. error-prevents-the-build-from-completing

This is because of the build agent that is selected by default for this template. The Hosted Agent is selected by default and this Hosted Agent only support project.json based Asp.Net Core Applications. It cannot compile .csproj based ASP.Net Core applications.

There is a simple solution for this issue, that is to change the build agent to Hosted VS2017 Agent which supports building .csproj based ASP.Net Core applications. To do this, in the Edit view of the build definition go to Options tab and in the Agents section, Select Hosted VS2017 Agent from the Default Agent Queue drop down.

3. select-vs2017-agent-from-default-agent-queue

You can also select the Agent from the Queue Build dialog where you can select the Agent used to build the project.

4. select-agent-from-queue-dialog

But you would want to select the Agent from the Options tab and save it to the build definition, especially if you are using this definition for Continuous Integration scenario where the build gets automatically triggered and you don’t get the chance to select the Agent.

With this change your build will successfully restore the NuGet packages and will complete the build without any issues.

5. successful-build-after-change

Advertisements

One thought on “Fix “Invalid input ‘WebApplication.csproj’. The file type was not recognized.” Error in Visual Studio Team Services, ASP.Net Core Build Definition

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s