You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generating a Dockerfile from VS with CPM enabled omits COPY for package props files #439
When using Central Package Management, the dockerfile generated is missing the required COPY statements for Directory.Build.props (contains the use CPM directive) and Directory.Packages.props. I'm generating the dockerfile with the standard "add new item... / docker support..." menu. I leave the defaults as is: linux, net8, dockerfile etc.
I tried declaring use CPM directly in the csproj but it also fails to add the requisite COPY statements in the dockerfile.
I'm using:
dotnet 8.0
Visual Studio (17.10)
Microsoft.VisualStudio.Azure.Containers.Tools.Targets(1.21.0)
nuget (6.10) -- not sure if this has anything to do with anything
Oisin Grehan (@oising) I was just checking, and it looks like we have do have a bug where if the Directory.Build.props file is in the same directory as the build context and project, we won't add the COPY statement. I'll get a fix out for that in 17.12.
Is that the same layout you have in your project that doesn't work or could you tell me the layout of your project with the locations of the solution, project, docker build context, and Directory.Build.props file please and I'll try to repo it.
Oisin Grehan (@oising) thank you for getting me that project layout. I fixed a bug we had for looking at files to copy more than 1 directory higher than the project (since yours were in the "groupingfolder") and it should be released in 17.12. Sorry I missed this case initially.
Activity
oising commentedon Aug 12, 2024
Patrick Verbrugge (@patverb) said:
The structure is like this:
yaml template (azure devops)
NOTE In Visual Studio 2022 (17.10 & 17.11) I can repro with "add new... docker support" menu item.
patverb commentedon Aug 12, 2024
Oisin Grehan (@oising) thank you for getting me that project layout. I fixed a bug we had for looking at files to copy more than 1 directory higher than the project (since yours were in the "groupingfolder") and it should be released in 17.12. Sorry I missed this case initially.
oising commentedon Aug 12, 2024
Excellent! thank you Patrick Verbrugge (@patverb) for the update. We've hand-modified the Dockerfile(s) to fix the issue by adding:
Putting this here for anyone else who finds this issue.
patverb commentedon Dec 1, 2025
This should be fixed in the latest release of visual studio.