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
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.
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.
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>
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.
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.