Publish Single File (Release) fails for WPF .NET Core 3.1 application

前端 未结 5 1832
南旧
南旧 2021-02-20 11:55

I\'m trying to publish a WPF Application (to a folder) targeting .NET Core 3.1, using Publish Single File, targeting win-x86. The application publishes fine for Debug, but fails

相关标签:
5条回答
  • 2021-02-20 12:02

    It is worth checking your Internet connection. I had a problem publishing self-contained deployment, because I was behind corporate firewall. Same error as yours:

    Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.

    And nothing more informative in that log file. After I disconnected VPN app was published with no errors.

    0 讨论(0)
  • 2021-02-20 12:09

    I had the same problem with a WPF application :

    VS2019 16.3 and dotnet Core 3.0 - publish worked fine.

    Updated to VS2019 16.4.1 and dotnet Core 3.1 - publish failed as described.

    Only difference is I am targeting X64.

    After multiple attempts editing the publish FolderProfile (none of which fixed the problem), I deleted the FolderProfile completely and created a new one targeting a different folder.

    Publish works again.

    Hope this helps.

    0 讨论(0)
  • 2021-02-20 12:12

    i have a same problem, in my case the solution is delete some dll of X86 system from .csproj file :

    <ItemGroup>
        <Reference Include="System.Management">
          <HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Management.dll</HintPath>
        </Reference>
      </ItemGroup> 
    
    0 讨论(0)
  • 2021-02-20 12:15

    I am getting the same issue, but I think mine is related to the project not even being able to build when I set "PublishSingleFile".

    I added a comment to their github issue post, assuming that it's a bug on their end since .net core 3.0 is publishing for me fine.

    0 讨论(0)
  • 2021-02-20 12:24

    For me the error has to do with custom nuget sources, like Azure DevOps Artifacts. Sometimes the build script tries to restore nugets from Azure DevOps and fails with a (Unauthorized) error, which produces the error in the post.

    Temporarily disabling the custom nuget sources, makes publish work again regardless of the options used like single file.

    0 讨论(0)
提交回复
热议问题