Clarification on the MSBuild property RestorePackagesConfig #13534
-
GoalI want to be able to (restore and) build both SDK-style and non-SDK C# projects using a single MSBuild command. Thought Process
Questions
<Project>
<PropertyGroup>
<RestorePackagesConfig>true</RestorePackagesConfig>
</PropertyGroup>
</Project> However, a bunch of
even though the projects are not. Notes
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
yes, msbuild works on SDK style projects. I think of Visual Studio as a GUI on top of MSBuild, so in most (but unfortunately not all) cases, if it works in VS, it'll probably work on the CLI with msbuild.
msbuild restore of packages.config doesn't work on a per-project setting. It needs to be passed into Nuget's RestoreTask. This is why I specified the
-p:RestorePackagesConfig=true
on the command line, which personally I recommend in CI scripts as well, but that's just my personal preference. But in theory copying thatDirectory.Build.props
example toDirectory.Solution.props
will work: https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-solution-build?view=vs-2022