NuGet from command line error - Microsoft.Build.Exceptions.InvalidProjectFileException

Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "E:\_PROJECTS\x\c\src\Services\Azure\.nuget\nuget.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. E:\_PROJECTS\x\c\src\Services\Azure\x\x.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args) at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(IElementLocation elementLocation, String resourceName, Object arg0) at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, String importExpressionEscaped, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator`4.Evaluate() at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ProjectInstance projectInstanceIfAnyForDebuggerOnly) at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation) at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings) at NuGet.Common.MSBuildProjectSystem.GetProject(String projectFile) at NuGet.Commands.UpdateCommand.GetMSBuildProject(String packageReferenceFilePath) at NuGet.Commands.UpdateCommand.ExecuteCommand() at NuGet.Commands.Command.Execute() at NuGet.Program.Main(String[] args)

The issue is depth; the nesting of projects in deeper folders for organisation seems to play havoc with the build file.
Pop open the CSProj file causing the issue,
alter the default path
SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> in the cs proj file.

Basically when you nest folders AFTER creating projects you'll need to do this.

Sorted.

Chris McKee

Chris McKee

https://chrismckee.co.uk

Software Engineer, Web Front/Backend/Architecture; all-round tech obsessed geek. I hate unnecessary optimism

View Comments