Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider disabling UseAppHost in generated Dockerfiles #3371

Closed
bwateratmsft opened this issue Jan 10, 2022 · 1 comment · Fixed by #3377
Closed

Consider disabling UseAppHost in generated Dockerfiles #3371

bwateratmsft opened this issue Jan 10, 2022 · 1 comment · Fixed by #3377

Comments

@bwateratmsft
Copy link
Collaborator

From @mthalman originally in microsoft/DockerTools#321


The Dockerfiles generated by VS include the following line:

RUN dotnet publish "WebApplication.csproj" -c Release -o /app/publish

This ends up outputting both a WebApplication executable and a WebApplication.dll library file in the output directory. Either file can be used to execute the app. The executable can be executed directly while the DLL requires the use of the .NET CLI (dotnet WebApplication.dll). From an image size perspective, it seems wasteful to include both files in the output. Only one of them is actually needed in order to execute the app. The Dockerfile is configured to only make use of the DLL:

ENTRYPOINT ["dotnet", "WebApplication31.dll"]

So it seems reasonable to simply not include the executable in the output.

By using the UseAppHost property, the publish logic can be configured to not include the executable in the output.

I propose that the Dockerfiles generated by the tools set this property by default:

RUN dotnet publish "WebApplication.csproj" -c Release -o /app/publish /p:UseAppHost=false
@bwateratmsft
Copy link
Collaborator Author

This is now released in Docker extension version 1.19.0.

@microsoft microsoft locked and limited conversation to collaborators Feb 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant