dotnet / sdk-container-builds

Libraries and build tooling to create container images from .NET projects using MSBuild
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
MIT License
181 stars 39 forks source link

warning NETSDK1198: A publish profile with the name 'DefaultContainer' was not found in the project #552

Closed dviry closed 9 months ago

dviry commented 9 months ago

When publishing a solution (about 30 projects), I get this warning on every project:

C:\Program Files\dotnet\sdk\8.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(204,5): 
warning NETSDK1198: A publish profile with the name 'DefaultContainer' was not found in the project. 
Set the PublishProfile property to a valid file name.

The container creation still works, but I think this warning should be handled (by not passing the PublishProfile to the inner build?)

Thanks in advance

baronfel commented 9 months ago

Unfortunately we can't really change this behavior easily. I'd suggest that instead of publish profiles at the solution level, you instead try using the MSBuild target directly: dotnet publish /t:PublishContainer - this behaves identically to the DefaultContainer PublishProfile method, but it also works for console applications and is the more MSBuild-native way of accomplishing the goal. We're moving towards this in all of our documentation and examples going forward.

dviry commented 9 months ago

This doesn't help much - now instead of warnings I am getting build errors (for each and every project):

error MSB4057: The target "PublishContainer" does not exist in the project

Maybe some info on how to adjust the .csproj to avoid those build errors?

Thanks

baronfel commented 9 months ago

If you upgrade to 8.0.200 that should just work, can you try that?

dviry commented 9 months ago

Installed 8.0.201 (was on 8.0.102) and it indeed resolved those build errors.

Thanks!