Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotnet restore MyProj.csproj thows "The file type is not recognised" on VSTS

I'm making my build pipeline for dotnet Core project. Part of my build script executes dotnet restore. I do it this way:

dotnet restore C:/Projects/MyProj/src/MyProj/MyProj.csproj

And it restores locally without a problem. When I push the same script to VSTS build server, in logs I see execution like this:

dotnet restore D:/a/1/s/src/MyProj/MyProj.csproj

but then I get error:

error: Invalid input 'D:/a/1/s/src/MyProj/MyProj.csproj'. The file type was not recognized.

What am I doing wrong? why does it work locally and not on VSTS.

I'm using the same version of dotnet.exe locally as on VSTS:

Version : 1.1.0
Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

I've got a global.json file sitting outside of src folder:

{
  "projects": ["src"],
  "sdk": {
    "version": "1.1.0"
  },
  "packages": "packages"
}

Folder structure as following:

   Root/
       build.cake
       build.ps1
       global.json
       src/
          MyProj.sln
          MyProj/
            MyProj.csproj
            *.cs
          MyProj.Tests/
            MyProj.Tests.csproj
            *.cs

Solution is created in VS2017, so this is latest csproj file format.

What else should I check?

like image 221
trailmax Avatar asked May 22 '17 16:05

trailmax


1 Answers

Since the project uses VS 2017 and the "released" .NET CLI tooling, you also need to use the Hosted VS2017 agent queue for the build so that the build will be run on an agent that has the necessary tools installed.

The version of the shared runtime host (dotnet.exe) is the same, the difference is that a newer CLI needs to be installed as well (which is in the sdk subdirectory of the directory where dotnet.exe is).

like image 188
Martin Ullrich Avatar answered Nov 11 '22 08:11

Martin Ullrich