title: Network share ClickOnce publish creates corrupt setup.exe
body: <p>I'm using <code>msbuild</code> (version 17.1.0+ae57d105c, from a VS 2022 Developer Command Prompt) to publish a ClickOnce application to a UNC path using the commandline. As such, I'm running what amounts to</p>
  <pre><code>&gt;msbuild /t:publish -p:PublishProfile=.\Properties\PublishProfiles\ClickOnceProfile.pubxml /p:PublishDir=\\some\unc\path\
  </code></pre>
  <p>Here, <code>ClickOnceProfile.pubxml</code> is more or less the default one generated by Visual Studio:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;!--
  https://go.microsoft.com/fwlink/?LinkID=208121.
  --&gt;
  &lt;Project&gt;
    &lt;PropertyGroup&gt;
      &lt;ApplicationRevision&gt;9&lt;/ApplicationRevision&gt;
      &lt;ApplicationVersion&gt;1.0.0.*&lt;/ApplicationVersion&gt;
      &lt;BootstrapperEnabled&gt;True&lt;/BootstrapperEnabled&gt;
      &lt;Configuration&gt;Release&lt;/Configuration&gt;
      &lt;CreateWebPageOnPublish&gt;False&lt;/CreateWebPageOnPublish&gt;
      &lt;GenerateManifests&gt;True&lt;/GenerateManifests&gt;
      &lt;Install&gt;True&lt;/Install&gt;
      &lt;IsRevisionIncremented&gt;True&lt;/IsRevisionIncremented&gt;
      &lt;IsWebBootstrapper&gt;False&lt;/IsWebBootstrapper&gt;
      &lt;MapFileExtensions&gt;True&lt;/MapFileExtensions&gt;
      &lt;OpenBrowserOnPublish&gt;False&lt;/OpenBrowserOnPublish&gt;
      &lt;PublishProtocol&gt;ClickOnce&lt;/PublishProtocol&gt;
      &lt;PublishReadyToRun&gt;False&lt;/PublishReadyToRun&gt;
      &lt;PublishSingleFile&gt;False&lt;/PublishSingleFile&gt;
      &lt;RuntimeIdentifier&gt;win-x64&lt;/RuntimeIdentifier&gt;
      &lt;SelfContained&gt;False&lt;/SelfContained&gt;
      &lt;SignatureAlgorithm&gt;(none)&lt;/SignatureAlgorithm&gt;
      &lt;SignManifests&gt;False&lt;/SignManifests&gt;
      &lt;TargetFramework&gt;net5.0-windows7.0&lt;/TargetFramework&gt;
      &lt;UpdateEnabled&gt;False&lt;/UpdateEnabled&gt;
      &lt;UpdateMode&gt;Foreground&lt;/UpdateMode&gt;
      &lt;UpdateRequired&gt;False&lt;/UpdateRequired&gt;
      &lt;WebPageFileName&gt;Publish.html&lt;/WebPageFileName&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemGroup&gt;
      &lt;BootstrapperPackage Include=&quot;Microsoft.NetCore.DesktopRuntime.5.0.x64&quot;&gt;
        &lt;Install&gt;true&lt;/Install&gt;
        &lt;ProductName&gt;.NET Desktop Runtime 5.0.16 (x64)&lt;/ProductName&gt;
      &lt;/BootstrapperPackage&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  <p>The command works and reports no errors:</p>
  <pre><code>Build succeeded.
      0 Warning(s)
      0 Error(s)
  </code></pre>
  <p>At this point, I would expect <code>\\some\unc\path\setup.exe</code> to be an executable that can be used to install the underlying application. However, the resulting <code>setup.exe</code> is a corrupt 1 kB file consisting mostly of 0x00.</p>
  <p>Moreover, if I use publish wizard in Visual Studio 2022, I run into the exact same issue.</p>
  <p>I've noticed that during publishing, <code>setup.exe</code> is some ~480 kB large while there's a small temporary file around as well, before <code>setup.exe</code> is ultimately replaced by the corrupt file.</p>
  <p>If I change the publish directory from a network path to, say, <code>bin\publish\</code>, the generated <code>setup.exe</code> (which is now 658 kB) works fine.</p>
  <p>Is this expected? Am I doing something wrong?</p>