microsoft / microsoft/WindowsAppSDK-Samples
build.cmd and VS builds have different 'packages' folders
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1k
- Forks
- 335
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 8
Description
build.cmd restores and builds with a specific packages directory:
call .nuget\nuget.exe restore "%%D" -configfile Samples\nuget.config -PackagesDirectory %~dp0packages
call msbuild /warnaserror /p:platform=%platform% /p:configuration=%configuration% /p:NugetPackageDirectory=%~dp0packages /bl:"%%~nD.binlog" "%%D"
which resolves to be :/packages. It's trying to amortize the C++ 'packages' directories for all of the solutions, which would help with disk usage and restore times. But since vcxproj's need to address the contents of the unpackaged NuGet packages, then the .vcxproj's would need to agree on the path to the 'packages' folder, and since it would be different between a build.cmd build and a Visual Studio IDE build, then there would need to be parameterization. But there isn't; I'm seeing build errors from build.cmd builds saying that the restore was successful but the vcxproj is failing to find files in the NuGet. For example, Samples\BackgroundTask\OutOfProc BackgroundTask\cpp-winui\BackgroundTaskBuilder\BackgroundTaskBuilder.vcxproj contains:
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props'))" />
With a 'build.cmd' restore, the 'packages' folder would be :/packages, and with a Visual Studio build it would be relative to the .sln file (Samples\BackgroundTask\OutOfProc BackgroundTask\cpp-winui\BackgroundTask_WinAppSDK.sln), so :/Samples/BackgroundTask/OutOfProc BackgroundTask/cpp-winui/packages.
It would be great to have consistent 'packages' folder for all .sln files, and all builds - that would be possible by setting the repositoryPath in the :/Samples/nuget.config file, and removing the logic from build.cmd. But that would require fixing up all of the paths in the .vcxproj files, and that seems like a lot of churn.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with build.cmd, Samples\nuget.config, and the example Samples\BackgroundTask\OutOfProc BackgroundTask\cpp-winui\BackgroundTaskBuilder\BackgroundTaskBuilder.vcxproj. Compare the packages paths used by build.cmd and the Visual Studio solution, then inspect the other .vcxproj files for the same assumptions. Done means all solution and build.cmd restores use a consistent packages folder and the affected builds find their NuGet files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100