MSBuildSdks
MSBuildSdks copied to clipboard
EnableCentralPackageVersions should be false for Docker Compose (dcproj) projects
I enabled CentralPackageVersion Sdk globally by adding this to Directory.Builds.targets
<Project >
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
</Project>
as to not having to specify the CentralPackageVersion for every project in my solution.
However that broke my build because I also have a Docker Compose project (.dcproj) in my solution
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
...
If I add <EnableCentralPackageVersions>false</EnableCentralPackageVersions>
to my Docker Compose project then it's all good again, but it feels like .dcproj should be added to Excluded Project Type Extensions
Though wouldn't be better to use an include list in Sdk.targets instead of an exclude list to control whether EnableCentralPackageVersions should be enabled for a project?
@martinstenhoff can you elaborate on what exactly broke? I'm interested to see the errors and what not, I haven't used a Docker Compose project yet. I'm all for adding it to the exclusion list if that sort of project doesn't support PackageReference items.
I have since moved on to NuGet's ManagePackageVersionsCentrally, but reverted back to using Microsoft.Build.CentralPackageVersions and then I realized the error is not coming from enabling the CentralPackageVersions Sdk globally alone. It's the combination with having a GlobalPackageReference that you get the following error (from dotnet build. VisualStudio seems to handle this without error):
NuGet.targets(132,5): error : Invalid restore input. Invalid target framework 'unsupported'. Input files: D:\git\CentralPackageVersions\docker\docker-compose.dcproj
docker-compose.dcproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>20a6bca2-57eb-480d-b90d-23ab97cb03a2</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
<DockerServiceName>frontend</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>
Would be good if GlobalPackageReferences would only inject PackageReferences into project types that support PackageReferences.
NuGet's ManagePackageVersionsCentrally has the same "problem" where ManagePackageVersionsCentrally has to be disabled in the docker-compose.dcproj if you are using global package references.
dotnet --version
7.0.100-rc.2.22477.23
dotnet nuget --version
NuGet Command Line
6.4.0.94