最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Cannot copy file apphost to the destination file , because the the destination file is a folder instead of a file - Stack O

programmeradmin3浏览0评论

I am building an application and using .NET 8.0. When I try to build the docker image, I'm getting an error saying that it cannot copy apphost to the destination as it's a folder instead of a file.

This is an ASP.NET Core 8.0 MVC application and I'm having issues only with it. No issues with other project for example APIs, etc.

Error MSB3024: Could not copy the file "//obj/Release/net8.0/apphost" to the destination file "bin/Release/net8.0/AppInterface", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. [/AppInterface.csproj]

AppInterface is the name of the assembly. I have tried changing it multiple times, also tried

<ItemGroup>
    <AppHostFile Include="obj/Release/net8.0/apphost" />
</ItemGroup>
    
<Target Name="CopyAppHost" AfterTargets="Build">
    <Copy SourceFiles="@(AppHostFile)" DestinationFiles="bin/Release/net8.0/apphost.exe" />
</Target>

I have tried all the solutions I was able to find online, but nothing that could actually work properly. There is one that didn't throw an error - I have added the line below in the .csproj file

<UseAppHost>false</UseAppHost>

The docker image is being created and after that pushed in the Azure container registry, however it looks like the view files and wwwroot folder cannot be found.

Any idea how I can solve this?

I am building an application and using .NET 8.0. When I try to build the docker image, I'm getting an error saying that it cannot copy apphost to the destination as it's a folder instead of a file.

This is an ASP.NET Core 8.0 MVC application and I'm having issues only with it. No issues with other project for example APIs, etc.

Error MSB3024: Could not copy the file "//obj/Release/net8.0/apphost" to the destination file "bin/Release/net8.0/AppInterface", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. [/AppInterface.csproj]

AppInterface is the name of the assembly. I have tried changing it multiple times, also tried

<ItemGroup>
    <AppHostFile Include="obj/Release/net8.0/apphost" />
</ItemGroup>
    
<Target Name="CopyAppHost" AfterTargets="Build">
    <Copy SourceFiles="@(AppHostFile)" DestinationFiles="bin/Release/net8.0/apphost.exe" />
</Target>

I have tried all the solutions I was able to find online, but nothing that could actually work properly. There is one that didn't throw an error - I have added the line below in the .csproj file

<UseAppHost>false</UseAppHost>

The docker image is being created and after that pushed in the Azure container registry, however it looks like the view files and wwwroot folder cannot be found.

Any idea how I can solve this?

Share Improve this question edited Feb 17 at 8:27 Palle Due 6,2924 gold badges20 silver badges34 bronze badges asked Feb 16 at 13:58 IvanIvan 632 silver badges13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I was able to solve the issue by myself, but posting this here in case someone is having the same issues. I have added this in the Dockerfile for the build and publish stages. This can be used in the Jenkins pipeline as well as it throw the same error.

/p:UseAppHost=false

It turned out that this can be also places in the csproj file as well as I did yesterday:

<UseAppHost>false</UseAppHost>

However the wwwroot folder was still missing, so I have added a line in the Dockerfile for that as well:

COPY --from=publish /app/publish/wwwroot ./wwwroot

Where /app/publish is the same path set in the publish stage.

After these changes, everything is working as expected.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论