microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

The command for copying Directory.Build.props is added to the template #369

Closed zhangzw218 closed 1 year ago

zhangzw218 commented 1 year ago

Describe the Problem I control the version of nuget with Directory.Build.props, but when constructing the dockerfile, I am warning because the file is not copied: warning NU1602 d does not provide an inclusive lower bound for dependency...

Describe the Solution I solved the problem by manually adding commands: COPY ["Sub_TitanAbpNextSolution/Directory.Build.props", "Sub_TitanAbpNextSolution/"]

Does the template automatically detect and add file copies, or does it already exist, but I have a configuration problem?

…… dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["nuget.config", "."]
COPY ["Sub_TitanAbpNextSolution/nuget.config", "Sub_TitanAbpNextSolution/"]
# I solved the problem by manually adding commands:
COPY ["Sub_TitanAbpNextSolution/Directory.Build.props", "Sub_TitanAbpNextSolution/"]
...

If I use Directory.Build. props, this file is a must. docker needs this file. If I didn't use Directory.Build. props, this file doesn't exist, Docker does not need this file. …… Or to put it another way, I think it should be something like nuget.config. If I don't have a custom configuration file, dockerfile won't copy it. If I customize nuget. config and have a file in the root directory, then the dockerfile will need to be copied automatically when it is generated. COPY ["nuget. config", "." ] This is automatically added to the dockerfile. …… I posted this issues on dotnet-docker: https://github.com/dotnet/dotnet-docker/issues/4398

patverb commented 1 year ago

Directory.Build.props should be scaffolded and added to new Dockerfiles automatically in Visual Studio Dev 17.6 preview 1.

zhangzw218 commented 1 year ago

@patverb Thank you. I will try it out as soon as the preview version comes out.

zhangzw218 commented 1 year ago

I have tested it on Visual Studio Dev 17.6 preview 1. This issue, is waiting for you to close.

dbreshears commented 1 year ago

Thanks for the confirmation @zhangzw218.

zhangzw218 commented 1 year ago

I updated the official version: 17.6.1, but did not have this function, was it cancelled for any reason @dbreshears

patverb commented 1 year ago

@zhangzw218 I just tested adding docker support to a new console app in 17.6.1 with a Directory.Build.props file in the project directory and it scaffolded the line COPY ["ConsoleApp1/Directory.Build.props", "ConsoleApp1/"] .

Are you doing anything different to what I described?

zhangzw218 commented 1 year ago

https://github.com/zhangzw218/AbpDemo/tree/feature/2023052601_zzw_Directory.Build.props vs 17.7.0 Preview 1.0 , there is a command to copy Directory.Build.props switch vs 17.6.2 , The command to copy Directory.Build.props is gone @patverb

patverb commented 1 year ago

@zhangzw218 I cloned your repo in VS 17.6.2 and right clicked on AbpDemo.Web -> Add Docker support and it re generated the docker file with Copy ["Directory.Build.props", "."].

I might not have made it clear before, but we don't ever update the dockerfile unless you re-scaffold it using the "Add Docker support" menu option.

zhangzw218 commented 1 year ago

After I reinstalled VS, everything is fine now. In retrospect, after the previous upgrade, the run will prompt a plug-in error, should be the upgrade process VS problems. Everything is fine now.