Reputation: 2025
Hello ALl I want to structure my project such that
| Build
Packages.props
| Output
| Source
Project1-Folder
Project1.csproj
Project2-Folder
Project2.csproj
Sln
Directory.Build.props
with Packages.props in this structure, it can't be recognized project 1, or 2 , but if I moved it to the root it works fine. any idea how to make it works under this structure
I tried using Directory props , but it gives circular error my Directory.Build.props looks like
<Project>
<PropertyGroup>
<EnableCentralPackageVersions>true</EnableCentralPackageVersions>
<CentralPackagesFile>$(MSBuildProjectDirectory)\Build\Packages.props</CentralPackagesFile>
</PropertyGroup>
</Project>
and packages.prop
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Update="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
Upvotes: 1
Views: 484
Reputation: 387677
You can specify the path to the Packages.props
file through the CentralPackagesFile
property. So you could add the following to your .csproj
files:
<PropertyGroup>
<CentralPackagesFile>$(MSBuildProjectDirectory)\..\..\Build\Packages.props</CentralPackagesFile>
</PropertyGroup>
Instead of adding this to every project separately, you can also create a Directory.Build.props
file to your project with the following contents:
<Project>
<PropertyGroup>
<CentralPackagesFile>$(MSBuildThisFileDirectory)\Build\Packages.props</CentralPackagesFile>
</PropertyGroup>
</Project>
Note that you will have to place this Directory.Build.props
file either in the root directory, or in your Source/
directory in order to have it picked up.
Upvotes: 1