Skip to content

build.cmd and VS builds have different 'packages' folders #553

@mschofie

Description

@mschofie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions