Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis-CI build failure "The type or namespace name 'Extensions' does not exist in the namespace"

Still new to Travis-CI and wanted to see if it's something I'm doing or not. I'm getting a build error in Travis-CI, but not locally.

Sample .NET Core 2.0 app. Going through the build I receive the following errors:

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

and

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

Here's a link to the config and job log:

https://travis-ci.org/ovation22/DapperRepository/jobs/273068340

like image 961
ovation22 Avatar asked Sep 08 '17 18:09

ovation22


1 Answers

There is a warning just above the error:

/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Configuration.Abstractions". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/travis/build/ovation22/DapperRepository/Example.Repository/Example.Repository.csproj]

DapperRepository.cs(7,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/travis/build/ovation22/DapperRepository/Example.Repository/Example.Repository.csproj]

DapperRepository.cs(16,33): error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?) [/home/travis/build/ovation22/DapperRepository/Example.Repository/Example.Repository.csproj]

Lets take a look at Example.Repository.csproj:

<ItemGroup>
  <PackageReference Include="Dapper" Version="1.50.2" />
</ItemGroup>

That looks fine. But where is Microsoft.Extensions.Configuration.Abstractions? Lets look a little lower:

<Reference Include="Microsoft.Extensions.Configuration.Abstractions">
  <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration.abstractions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
</Reference>

So you are telling msbuild that it is available at C:\Program Files. Travis is running this in Linux where this path obviously doesnt exist.

Try adding a PackageReference just like Dapper in that csproj. That should fix this.

like image 50
omajid Avatar answered Oct 15 '22 07:10

omajid