I've just migrated my .NET 4.8 Windows Forms application to .NET 5. The process was incredibly easy. The only problem I'm having is with Deploy. I've been using Click Once deploy with my application for years but after changing it to .NET5 and recreating the deploy, I'm getting this error. I also get the same error if I use the simpler Folder (non Click Once) deploy option. I'm deploying to a server share folder (\\HYDRA\Data\SL\IceTool
) which is writable (the deploy task does actually copy the application executable into the share folder - but nothing else).
The error appears in a dialogue box containing the following text:
Publish has encountered an error. Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
A diagnostic log has been written to the following location: "C:\Users\Chris\AppData\Local\Temp\tmpF29C.tmp"
The tmpF29C.tmp
file contains:
17/12/2020 01:05:34 System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. --- End of inner exception stack trace --- ---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
===================
Checking the output build log shows that the solitary Ice.exe
file is "being used by another process":
2>Native image obj\Release\net5.0-windows\win-x64\R2R\Ice.dll generated successfully.
2>Skipping target "_CreateR2RSymbols" because it has no outputs.
2>Though the target has declared its outputs, the output specification only references empty properties and/or empty item lists.
2>Task "NETSdkError" skipped, due to false condition; ('@(_ReadyToRunCompilationFailures)' != '') was evaluated as ('' != '').
2>Task "NETSdkInformation" skipped, due to false condition; ('$(_ReadyToRunCompilerHasWarnings)' != '') was evaluated as ('' != '').
2>Target "GeneratePublishDependencyFile" skipped, due to false condition; ('$(GenerateDependencyFile)' == 'true' and '$(_UseBuildDependencyFile)' != 'true') was evaluated as ('true' == 'true' and 'true' != 'true').
2>Target "ComputeDependencyFileCompilerOptions" skipped, due to false condition; ('$(PreserveCompilationContext)' == 'true') was evaluated as ('' == 'true').
2>Building target "GenerateSingleFileBundle" completely.
2>Input file "C:\Workspaces\Framework\Main\Source\Core\Ice\obj\Release\net5.0-windows\win-x64\apphost.exe" is newer than output file "\\HYDRA\Data\SL\IceTool\Ice.exe".
2>Task "NETSdkError" skipped, due to false condition; ('$(IncludeAllContentForSelfExtract)' == 'true' And '$(IncludeNativeLibrariesForSelfExtract)' != 'true') was evaluated as ('false' == 'true' And 'false' != 'true').
2>Using "GenerateBundle" task from assembly "C:\Program Files\dotnet\sdk\5.0.101\Sdks\Microsoft.NET.Sdk\targets\..\tools\net472/Microsoft.NET.Build.Tasks.dll".
2>The "GenerateBundle" task failed unexpectedly.
2>System.IO.IOException: The process cannot access the file '\\HYDRA\Data\SL\IceTool\Ice.exe' because it is being used by another process.
2> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
2> at 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)
2> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
2> at System.IO.File.OpenWrite(String path)
2> at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
2> at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore()
2> at Microsoft.NET.Build.Tasks.TaskBase.Execute()
2> at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2> at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2>Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Auto' == 'On' or (''!='' and 'Auto' == 'Auto')).
2>Comparison path is "C:\Workspaces\Framework\Main\Source\Core\Ice".
2>Comparison path is "bin\Release\net5.0-windows\win-x64\".
2>Comparison path is "obj\Release\net5.0-windows\win-x64\".
========== Build: 1 succeeded, 0 failed, 4 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
The deploy target folder (initially empty) contains just the single Ice.exe
file. The same file that is "in use".
Here is my ClickOnceProfile.pub.xml file:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<GenerateManifests>True</GenerateManifests>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<InstallUrl>\\HYDRA\Data\SL\IceTool\</InstallUrl>
<IsRevisionIncremented>True</IsRevisionIncremented>
<IsWebBootstrapper>False</IsWebBootstrapper>
<ManifestCertificateThumbprint>(removed!)</ManifestCertificateThumbprint>
<MapFileExtensions>true</MapFileExtensions>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<Platform>Any CPU</Platform>
<ProductName>IceTool</ProductName>
<PublishDir>\\HYDRA\Data\SL\IceTool\</PublishDir>
<PublishUrl>\\HYDRA\Data\SL\IceTool\</PublishUrl>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishSingleFile>True</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>sha256RSA</SignatureAlgorithm>
<SignManifests>True</SignManifests>
<TargetCulture>en-GB</TargetCulture>
<TargetFramework>net5.0-windows</TargetFramework>
<UpdateEnabled>True</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.5.0.x64">
<Install>true</Install>
<ProductName>.NET Desktop Runtime 5.0.1 (x64)</ProductName>
</BootstrapperPackage>
</ItemGroup>
</Project>
Could this be a bug in a relatively new framework release? (Parallel task condition?) or any I doing something wrong. Thanks.