novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
347 stars 42 forks source link

Build failing due to empty ToolDepsJsonGeneratorProject value #190

Open MiguelAlho opened 4 years ago

MiguelAlho commented 4 years ago

Hi. We have a WPF project that uses the Sdk, and we recently made a few changes to both the project (update from 1.6.68 to 2.0.54), but also some upgrades on the build agent (a Team City agent ). Agent-wise, we recently updated the VS instance we have on it , to have access to some tools that are included.

After this change (not applied on all agents yet) we started to get the following error:

´´´ C:\Users\.nuget\packages\msbuild.sdk.extras\2.0.54\Sdk\Sdk.props(16,5): error MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form. [path-to-project.csproj] ´´´

I started investigating, and this only occurs on the agent where we upgraded the VS instance. We have an agent that did not have this upgrade that can still build the project correctly (15.9 compiler).

From what I can see, in the ´sdk.props´ file and the log, our value for $(ToolDepsJsonGeneratorProject) is empty (and code only goes through this because $(MicrosoftWindowsDesktopSdkPath) is also empty/unset. Is there any SDK elements (like windows SDK) or some VS feature that needs to be installed to have this set correctly?

Our cake-based build process is specifically detecting that it is an extras project and is using the VS msbuild instead of the .net core version (though our solution mixed both types of projects).

mfkl commented 4 years ago

Hitting this as well with vmImage vs2017-win2016 and "MSBuild.Sdk.Extras": "2.0.54" global json and .NET Core SDK 3.0.x. Updating to the windows-2019 vmImage fixes it for me.

clairernovotny commented 4 years ago

@MiguelAlho I'm not completely sure what's going on, ToolDepsJsonGeneratorProject should be set early by the .NET Core SDK. If you're using VS 2019, do you have 16.3 on it and do you have the .NET Core workload installed?

mfkl commented 4 years ago

Have a consistent repro here if you're interested @onovotny https://github.com/videolan/libvlcsharp/pull/71#issuecomment-540333184

azchohfi commented 4 years ago

I'm hitting the same error when targeting .Net Core 3.1.100.

jwdb commented 4 years ago

The issue was solved for me by changing the SDKversion in the global.json from 3.0.100 to 3.1.100. I did not have .Net Core 3.0.100 installed, so it might be happening the targeted SDK version is not installed?