nuget.exe fail: Missing required property 'OutputPath' for project type 'PackageReference'

2

(Using nuget.exe version 4.9.2 and Visual Studio 2017 Community Edition)

I'm stumped on a nuget.exe restore issue. I'm using Jenkins to build pushed sources. I had a solution with a single project in it, Roadmap, and that built fine, including using

nuget.exe restore "test.sln"

to restore the nuget packages. My Jenkins builds always start with an empty directory.

Now I have a second project. It uses several of the same nuget packages. But when Jenkins runs the same nuget.exe command on the .sln file, I get this error:

C:\Jenkins\workspace\test>nuget restore "test.sln"
MSBuild auto-detection: using msbuild version '12.0' from 'C:\Program Files (x86
)\MSBuild\12.0\bin\amd64'.
All packages listed in packages.config are already installed.
Invalid restore input. Missing required property 'OutputPath' for project type '
PackageReference'. Input files: C:\Jenkins\workspace\test\Roadtrip\Roadtrip.csproj.

I do see the OutputPath set in both of the .csproj files in my solution. But the error message isn't completely misleading. Roadmap.csproj, the original, has lines like these for the nuget packages:

  <ItemGroup>
     <Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
       <HintPath>..\packages\CommonServiceLocator.2.0.4\lib\net45\CommonServiceLocator.dll</HintPath>
     </Reference>
  ...

In Roadtrip.csproj, the new one, the equivalent section holds

  <ItemGroup>
     <PackageReference Include="CommonServiceLocator">
        <Version>2.0.4</Version>
     </PackageReference>
  ...

This is the case whether I use the solution nuget manager to add packages to one or both projects, or use each project nuget manager to add their packages.

From what I've seen online, Roadtrip that looks fine. I'm not sure why it would differ from Roadmap. From within Visual Studio, the references are found and both apps run, with the correct DLLs sitting in the debug and release directories. Additionally, when I run the nuget.exe line on my laptop, the packages are retrieved.

It's only when I run it on the remote Jenkins server that it fails. I've tried looking for the differences in the configurations, but they're not jumping out, what I can find that's relevant matches on both. I'm hoping there's someone knowledgeable here who knows the specifics of why I'd see that error message.

I appreciate any assistance.

Update: I was going to add this in the morning, and Scott mentioned doing so as well... I'm picking on Jenkins, but it's really the machine Jenkins is running on. I can open a cmd window on my laptop (not the MSVC cmd window), wipe out the solution packages directory and all obj/bin subdirectories, and nuget.exe restore test.sln completes successfully. Doing the same on the machine with Jenkins fails as shown above... and used to work before I added the second project. The versions of nuget and Visual Studio are the same on both, the environment variables in the cmd windows are the same on both.

trueskew

Posted 2018-12-21T01:14:22.623

Reputation: 21

Can you clarify "It's only when I run it on the remote Jenkins server that it fails."? Please do not respond in comments; [edit] your question to make it clearer and more complete. – Scott – 2018-12-21T01:37:54.857

Did you try nuget.exe update -self? – JB. With Monica. – 2019-02-05T11:07:45.323

Hi JB... I did. – trueskew – 2019-02-06T15:30:01.930

Answers

2

I had the same issue while restoring locally, and it worked as expected. But when I tried and started my job on the Jenkins agent, I got the same issue with the nuget restore.

nuget restore pathToProject\MyProject.csproj

Invalid restore input. Missing required property 'OutputPath' for project type 'PackageReference'. Input files: MyProject.csproj

Where on my Jenkins Agent machine I had the same Nuget version as the Nuget version on my machine. And the same MSBuild as my MSBuild on my machine.

But the nuget restore command started another MSBuild version on my agent. Specifying the MSBuildPath to the MSBuild version 15, helped in my case.

nuget restore pathToProject\MyProject.csproj -MSBuildPath "pathToMSBuild\MSBuild\15.0\Bin"

Or you might try using -MSBuildVersion.

As far as I understand the PackageReference change works best with MSBuild version 15. Since it came with Visual Studio 2017, and at the same time MSBuild 15.

In case you still wanted to use ProjectReference, and do not revert to Packages.Config. Using MSBuild 15 should help, and in my case it did help in doing so. But going with packages.config and staying with the same MSBuild should also work without any issue.

Malenko

Posted 2018-12-21T01:14:22.623

Reputation: 21

0

My working answer is that the Visual Studio / nuget.exe versions I'm using do not support PackageReference in .csproj files. I've read that it should, but couldn't get past this issue. Once I modified my Roadmap project to use packages.config and modified my .csproj file to match the Roadmap file, the nuget restore command worked as expected.

trueskew

Posted 2018-12-21T01:14:22.623

Reputation: 21