Can not publish .NET Core 8 standalone exe

127 Views Asked by At

I currently have the following problem.

I have a .NET Core 8 solution which contains 2 projects.

  1. Shared <- Windows Forms App (publish with no errors)
  2. Client <- Windows Forms App (publish with error - standlone exe and self contained)

Error:

Unexpected error in the GenerateBundle task. Client \bin\Release\net8.0-windows\win-x64\app.publish\Shared.deps.json" could not be found.

Dateiname: "\Client\bin\Release\net8.0-windows\win-x64\app.publish\Shared.deps.json"

bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
bei Microsoft.NET.HostModel.Bundle.Bundler.IsAssembly(String path, Boolean& isPE)
bei Microsoft.NET.HostModel.Bundle.Bundler.InferType(FileSpec fileSpec)
bei Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
bei Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore()
bei Microsoft.NET.Build.Tasks.TaskBase.Execute()
bei Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

The missing file Shared.deps.json is located in <Removed>\Client\bin\Release\net8.0-windows\win-x64 and not the subfolder app.publish.

There are no other errors in the output. Starting the application inside Visual Studio in Debug and Release Mode works normally.

Used frameworks by both .csproj:

  • Microsoft.NETCore.App
  • Microsoft.WindowsDesktop.App.WindowsForms

The following Nuget packages are used in Client.csproj:

  • Npgsql (8.0.1)
  • System.Management (8.0.0)
  • MaterialSkin.2 (2.31.)

Com references in Client.csproj:

  • IWshRuntimeLibrary

The following Nuget packages are used in Shared.csproj:

  • Microsoft.Data.Sqlite (8.0.2)
  • Microsoft.Data.Sqlite.Core (8.0.2)
  • System.data.SQLite.Core (1.0.118)
  • MaterialSkin.2 (2.31.)

Client.csproj file:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <AssemblyName>ClientInstaller</AssemblyName>
        <ApplicationIcon>Resources/Icon.ico</ApplicationIcon>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net8.0-windows</TargetFramework>
        <Nullable>enable</Nullable>
        <UseWindowsForms>true</UseWindowsForms>
        <ImplicitUsings>enable</ImplicitUsings>
        <PublishSingleFile>true</PublishSingleFile>
        <SelfContained>true</SelfContained>
        <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    </PropertyGroup>

    <ItemGroup>
        <None Remove="Resources\Driver.exe" />
        <None Remove="Resources\NET.zip" />
    </ItemGroup>

    <ItemGroup>
        <COMReference Include="IWshRuntimeLibrary">
            <WrapperTool>tlbimp</WrapperTool>
            <VersionMinor>0</VersionMinor>
            <VersionMajor>1</VersionMajor>
            <Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid>
            <Lcid>0</Lcid>
            <Isolated>false</Isolated>
            <EmbedInteropTypes>true</EmbedInteropTypes>
        </COMReference>
    </ItemGroup>

    <ItemGroup>
        <EmbeddedResource Include="Resources\Driver.exe" />
        <EmbeddedResource Include="Resources\InstallationFiles.zip" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Npgsql" />
        <PackageReference Include="System.Management" />
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\Shared\Shared.csproj">
            <Private>True</Private>
        </ProjectReference>
    </ItemGroup>

    <ItemGroup>
        <Folder Include="Properties\" />
    </ItemGroup>

</Project>

I have absolutely no idea what the problem could be here.

Even googling didn't really get me any further. I just need a way to publish the software as a single-file application.

I hope you can give me a tip on what to look for.

Thanks in advance!

0

There are 0 best solutions below