MSBuildForUnity icon indicating copy to clipboard operation
MSBuildForUnity copied to clipboard

.csproj files within a local UPM can't find MSBuildForUnity.Common.props

Open mschofie opened this issue 5 years ago • 0 comments

I'm attempting to follow Scenario 4: Distribute a UPM Package w/ NuGet Dependency. Based on my understanding of the documentation, I have:

  1. Added a '.csproj' file to my UPM that announces the NuGet dependencies that my UPM needs.
  2. Made com.microsoft.msbuildforunity a dependency of the UPM

When adding the UPM to an existing Unity project the com.microsoft.msbuildforunity integration kicks in, and I see the command-line invoked:

[package location]\Runtime> C:\Program Files\dotnet\dotnet.exe msbuild [packagename].csproj -restore  -v:minimal -p:NuGetInteractive=true  -t:Build -p:Configuration=Release

But since the [package location] - for local packages - is outside the scope of the Unity project, then the line:

<Import Project="$([MSBuild]::GetPathOfFileAbove(MSBuildForUnity.Common.props))" Condition="Exists('$([MSBuild]::GetPathOfFileAbove(MSBuildForUnity.Common.props))')" />

is a no-op, since the condition evaluates to false. There doesn't appear to be a way - given the command-line invoked - to identify the Unity project folder.

Proposal

Have the com.microsoft.msbuildforunity Unity scripts pass the Application.dataPath into the dotnet msbuild invocation as an MSBuild property would make the import a lot more clear.

mschofie avatar Oct 06 '20 22:10 mschofie