nuget.targets was not found

pantarheipantarhei Posts: 3
edited September 10, 2013 10:50AM in Deployment Manager
I'm trying to publish an application package with the VS addon. As soon I try to publish I get the following error:
An error occurred while creating and pushing the package

The imported project "C:\Projects\.nuget\nuget.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  C:\Projects\MyProject\Web\MyProject.Web.csproj

In my csproj file I have the following line. I think it belongs somehow to the nuget package restore.
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

But I have no idead why the addon tries to load something from the project root. Any help on this?


  • In order to create the package, the Deployment Manager VS extension will compile your code, so that it can put the compiled binaries into the package.

    From the error message, it looks like it was failing to compile your code.

    Can you check your C:\Projects\MyProject\Web\MyProject.Web.csproj file in Notepad for me. Does it have this line (or something like it) in the first PropertyGroup:
        <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
    My hunch is that it has this line with the value "..\..\" instead of "..\". Try switching to "..\", reloading the project in VS, repackaging it, and see what happens.

    The background is that SolutionDir isn't set by our VS extension, and normally NuGet would automatically add that line so that the csproj still compiles even if SolutionDir isn't set. It looks like SolutionDir is being set to the wrong thing by the csproj, which causes the nuget.targets file to not be found error to happen.
  • Great hint. Looks like that fixed my issue. Don't know how long it would have taken me to find. :)
Sign In or Register to comment.