I have run into a strange issue in Visual Studio 2017. Recently a change in our internal nuget packages moved a class, that is used in an extension, to another project/package, but the namespace was not changed. Upon updating the new packages in another solution the extension methods began all throwing compile errors.
"Reference to type 'x' claims it is defined in 'y', but it could not be found"
I can get the solution to build by, changing the extension method to be used as static invocations, using Visual Studio 2013, or having resharper build use msbuild 12 (14 and 15 throw the same error).
I have tried clearing cache, deleting packages and restoring, restarting everything, and a fresh checkout in a separate folder. Also looked at other questions that had the same error, but nothing they mentioned worked.
I do plan to make the team that moved the class to fix the namespace to match the project, but it will take a few weeks to get it through.
Ex:
//In project Company.Auto
namespace Company.Auto.Extensions
{
using System;
public static class Cars
{
public static IDictionary<string, Car> DoStuff(this Car car)
{
}
}
}
//Moved to project Company.Stuff.Something.Documents
namespace Company.Auto.Domain
{
using System;
public class Car
{
}
}