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 badges1 Answer
Reset to default 1I 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.