Skip to content

CopyToPublishDirectory does not work in .net9. #46073

Open
@neominky

Description

CopyToPublishDirectory does not work after changing from .net8 to .net9. So file conflict occurs.

21>C:\Program Files\dotnet\sdk\9.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(112,5): 오류 NETSDK1152: 상대 경로가 같은 여러 게시 출력 파일을 찾았습니다. P:\Projects\MyCompany\MyProduct\src\MyProduct.Api\aspnet-core\src\MyProduct.Api.Client.Windows\appsettings.json, P:\Projects\MyCompany\MyProduct\src\MyProduct.Api\aspnet-core\src\MyProduct.Api.Client.Web.Host\appsettings.json, P:\Projects\MyCompany\MyProduct\src\MyProduct.Api\aspnet-core\src\MyProduct.Api.Client.Windows\appsettings.Production.json, P:\Projects\MyCompany\MyProduct\src\MyProduct.Api\aspnet-core\src\MyProduct.Api.Client.Web.Host\appsettings.Production.json.

MyProduct.Api.Client.Web.Host

		<None Update="appsettings.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
			<CopyToPublishDirectory>false</CopyToPublishDirectory>
			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
		</None>
		<None Update="appsettings.Production.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
			<CopyToPublishDirectory>false</CopyToPublishDirectory>
			<DependentUpon>appsettings.json</DependentUpon>
			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
		</None>

MyProduct.Api.Client.Windows

		<Content Include="appsettings.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
			<CopyToPublishDirectory>Always</CopyToPublishDirectory>
		</Content>
		<Content Include="appsettings.Production.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
			<DependentUpon>appsettings.json</DependentUpon>
			<CopyToPublishDirectory>Always</CopyToPublishDirectory>
		</Content>

any temporary solution?

added --- The problem has been solved.
MyProduct.Api.Client.Web.Host:
Change None to Content in MyProduct.Api.Client.Web.Host
Image

MyProduct.Api.Client.Windows:
Remove None+Remove from MyProduct.Api.Client.Windows. I don't know why this is there. VisualStudio added it.
Image

It is true that this is not a problem in .net8.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions