Winforms Windows窗体“;“部署任务”;不符合;该进程无法访问该文件,因为另一进程正在使用该文件。”;in.NET5

Winforms Windows窗体“;“部署任务”;不符合;该进程无法访问该文件,因为另一进程正在使用该文件。”;in.NET5,winforms,clickonce,.net-5,Winforms,Clickonce,.net 5,我刚刚将.NET 4.8 Windows窗体应用程序迁移到.NET 5。这个过程非常简单。我唯一的问题是部署。多年来,我一直在我的应用程序中使用Click Oncedeploy,但在将其更改为.NET5并重新创建deploy之后,我遇到了这个错误。如果使用更简单的文件夹(非单击一次)部署选项,也会出现相同的错误。我正在部署到一个服务器共享文件夹(\\HYDRA\Data\SL\IceTool),该文件夹是可写的(部署任务实际上会将应用程序可执行文件复制到共享文件夹中,但没有其他内容) 错误出现在

我刚刚将.NET 4.8 Windows窗体应用程序迁移到.NET 5。这个过程非常简单。我唯一的问题是部署。多年来,我一直在我的应用程序中使用Click Oncedeploy,但在将其更改为.NET5并重新创建deploy之后,我遇到了这个错误。如果使用更简单的文件夹(非单击一次)部署选项,也会出现相同的错误。我正在部署到一个服务器共享文件夹(
\\HYDRA\Data\SL\IceTool
),该文件夹是可写的(部署任务实际上会将应用程序可执行文件复制到共享文件夹中,但没有其他内容)

错误出现在包含以下文本的对话框中:

发布遇到错误。 发布遇到错误。我们无法确定错误的原因。有关更多详细信息,请查看输出日志

诊断日志已写入以下位置: “C:\Users\Chris\AppData\Local\Temp\tmpF29C.tmp”

tmpF29C.tmp
文件包含:

2020年12月17日01:05:34 System.AggregateException:发生一个或多个错误。-->Microsoft.WebTools.Shared.Exceptions.WebToolsException:发布遇到错误。我们无法确定错误的原因。有关更多详细信息,请查看输出日志。 ---内部异常堆栈跟踪的结束---
--->(内部异常#0)Microsoft.WebTools.Shared.Exceptions.WebToolsException:发布遇到错误。我们无法确定错误的原因。有关更多详细信息,请查看输出日志。您的应用程序是否仍在后台运行?或者可能是防病毒软件锁定了可执行文件?您可以检查应用程序是否在任务管理器中运行。您可以检查其他进程是否已使用或打开了可执行文件的句柄。如果您尝试发布到本地文件夹,是否会出现相同的错误?应用程序未在后台运行。一天后(重启后)我又回到了这个问题上,但问题仍然存在。AV是一种可能性/当我以本地桌面(子文件夹)为目标时,部署工作正常。我可以接受这一点——我只需要在之后将其重新定位到共享。幸运的是,您可以将最终UNC路径指定为发布设置的一部分。谢谢。发布必须在某个时候修改它创建的文件。如果发布文件夹是远程文件夹,则此过程会慢得多,并且可能会被可能的一次写入权限阻止。很有可能而且实际上希望只给某人
创建
权限,以避免上传文件后对其进行修改。如果您在本地发布,然后复制到远程文件夹,整个过程会快得多。您的应用程序是否仍在后台运行?或者可能是防病毒软件锁定了可执行文件?您可以检查应用程序是否在任务管理器中运行。您可以检查其他进程是否已使用或打开了可执行文件的句柄。如果您尝试发布到本地文件夹,是否会出现相同的错误?应用程序未在后台运行。一天后(重启后)我又回到了这个问题上,但问题仍然存在。AV是一种可能性/当我以本地桌面(子文件夹)为目标时,部署工作正常。我可以接受这一点——我只需要在之后将其重新定位到共享。幸运的是,您可以将最终UNC路径指定为发布设置的一部分。谢谢。发布必须在某个时候修改它创建的文件。如果发布文件夹是远程文件夹,则此过程会慢得多,并且可能会被可能的一次写入权限阻止。很有可能而且实际上希望只给某人
创建
权限,以避免上传文件后对其进行修改。如果您在本地发布,然后复制到远程文件夹,整个过程将快得多
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 ==========
<?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>