there is a legacy .NET Framework solution with many projects. CI pipeline (Gitlab) has several jobs:
- Restores nugets to the specific folder and takes the folder as an artifact.
- Uses the artifact nugets to build the solution
- ...
- Uses the artifact for another tasks.
I need to migrate the solution to the latest .NET version, but I can't use the big bang approach, cause it would require a lot of effort and would stop other development tasks. The first step is to migrate from packages.config to PackageReference.
After the migration, I've faced a problem. Since PackageReference packages are maintained in the global-packages folder I can't take them as an artifact and reuse in another jobs.
I've tried:
- Add a nuget.config file with xml content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="..\packages" />
</config>
</configuration>
- Restore nugets using command line:
nuget restore Solution.sln -Force
. The globalPackagesFolder parameter works, command line restore nuget packages to the custom folder. - Gitlab job configured to take "packages" folder as an artifact and add the folder in the next jobs where these nugets are required. Works as expected.
- Build solution using command line:
msbuild Solution.sln /maxcpucount /nologo /property:Configuration=Debug /verbosity:minimal /t:Rebuild /nr:false /p:RestorePackagesPath=packages | Write-Host
- Fail!
Sadly, but msbuild can't see nuget packages even with p:RestorePackagesPath=packages
parameters and throws a lot of errors with missing reference text. Could you please explain why msbuild can't use custom folder packages? How I could fix my code/configs to make it work?