Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS - Building ASP.NET Core 2.0, compile error: Could not locate the assembly "Microsoft.AspNetCore.Mvc.ViewFeatures"

VSTS build of my ASP.NET Core 2.0 MVC app fails with these warnings:

Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Mvc.ViewFeatures". Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Logging.Abstractions". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. Warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Data.SqlClient". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

And then I get compilation error like these:

The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Error CS0246: The type or namespace name 'ILogger' could not be found (are you missing a using directive or an assembly reference?)

and so on for ILoggerFactory, SqlDataReader, etc. And everything builds perfectly on my machine locally. What am I missing?

like image 738
alvipeo Avatar asked Sep 04 '17 15:09

alvipeo


1 Answers

  • First please make sure the PackageReference in .csproj are not refer the local paths. It should like:

    <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
    <PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
    

  • Then please use ASP.Net Core template to define your build definition:

    With the .NET Core tasks to restore, build, test and publish, and you can also add other tasks for your needs.

    enter image description here

like image 67
Marina Liu Avatar answered Sep 21 '22 04:09

Marina Liu