.NET publish in Azure error MSB3094: "DestinationF...
# help-with-umbraco
l
I'm at a loss. I have a very simple, practically empty Umbraco 15 project with only uSync and a private package installed. It will publish locally, but it will not publish in Azure. When executing the dotnetcli task in Azure, I see that it executes the following command:
Copy code
/opt/hostedtoolcache/dotnet/dotnet publish /home/vsts/work/1/s/Test/Test.csproj --configuration Release --output /home/vsts/work/1/a/Test'
It will fail with the following error:
Copy code
/opt/hostedtoolcache/dotnet/sdk/9.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(355,5): error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 435 item(s). They must have the same number of items.
I think it something to do with the files that are being copied, but that's not something that changes between Umbraco 13 and 15 as far as I know and this pipeline has been in use for quite some time.
Copy code
Test -> /home/vsts/work/1/s/TestDockerDeploymentSlot/bin/Release/net9.0/Test.dll
Copying JSON schema files into project directory: appsettings-schema.usync.json;appsettings-schema.Umbraco.Cms.json;appsettings-schema.ProudNerds.Umbraco.Core.json;appsettings-schema.ProudNerds.Umbraco.Core.Headless.json
Copying JSON schema files into project directory: umbraco-package-schema.json
Adding JSON schema references to appsettings-schema.json: https://json.schemastore.org/appsettings.json;appsettings-schema.usync.json#;appsettings-schema.Umbraco.Cms.json#;appsettings-schema.ProudNerds.Umbraco.Core.json#;appsettings-schema.ProudNerds.Umbraco.Core.Headless.json#
Because the site is practically empty and a local publish works as expected, I'm at a loss what could be causing this. The only difference is that the build pipeline is Linux and my local machine Windows. Any idea?
For the completeness, this is the project file. It's really simple and contains almost nothing:
Copy code
xml
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <CompressionEnabled>false</CompressionEnabled> <!-- Disable compression. E.g. for umbraco backoffice files. These files should be precompressed by node and not let dotnet handle it -->
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ProudNerds.Umbraco.Headless" Version="4.0.0-beta202502101" />
    <PackageReference Include="Umbraco.Cms" Version="15.2.0" />
  </ItemGroup>

  <ItemGroup>
    <!-- Opt-in to app-local ICU to ensure consistent globalization APIs across different platforms -->
    <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
    <PackageReference Include="uSync" Version="15.1.1" />
    <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="72.1.0.3" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Views\Partials\Components\" />
  </ItemGroup>

  <PropertyGroup>
    <!-- Razor files are needed for the backoffice to work correctly -->
    <CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
  </PropertyGroup>
</Project>
s
What is a local publish for you? Start with
dotnet clean -c Release
and then:
dotnet publish MyProject1520.csproj Release --output E:\Release
Where
E:\Release
is an empty folder.
And also.. worth a try: does it work on the server when you remove
<PackageReference Include="ProudNerds.Umbraco.Headless" Version="4.0.0-beta202502101" />
? Then at least we'd know where to look.
l
Yes, that's what I meant and that's why I did locally and that works perfectly fine
s
<Folder Include="Views\Partials\Components\" />
is also new, so might want to try without that line on the server as well.
you'll probably get other errors, but it will hopefully point at least to the source of the problem.
k
What's the purpose of the folder include?
l
I guess it's a left over from the StarterKit I had installed before. To make sure nothing custom is messing about, I created a new 15(.2.0) website with NOTHING custom and now I'm getting the following error:
Copy code
/opt/hostedtoolcache/dotnet/dotnet publish /home/vsts/work/1/s/TestClassicSlot/TestClassicSlot.csproj --configuration Release --output /home/vsts/work/1/a/TestDockerDeploymentSlot' /p:PublishDir=/home/vsts/work/1/a --no-restore
/opt/hostedtoolcache/dotnet/sdk/9.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file '/home/vsts/work/1/s/TestClassicSlot/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/vsts/work/1/s/TestClassicSlot/TestClassicSlot.csproj]
oh wait, --no-restore needs to go lol
s
--no-restore
will do that to you 😉
l
With --no-restore removed we're back to this:
Copy code
/opt/hostedtoolcache/dotnet/sdk/9.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(355,5): error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 241 item(s). They must have the same number of items. [/home/vsts/work/1/s/TestClassicSlot/TestClassicSlot.csproj]
I'm wondering is something changed in dotnet 9 on the publish command. But this is on a completely empty Umbraco 15.2.0 project.
s
seems unlikely.. I've not deployed it like this though so not sure what "refers to 1 item(s)" means..
l
The task as defined in my yml file:
Copy code
# Publish the project to the staging directory
  - task: DotNetCoreCLI@2
    displayName: '.NET: publish solution'
    inputs:
      command: 'publish'
      feedsToUse: 'select'
      vstsFeed: '#REDACTED#'
      arguments: '--configuration ${{ variables.configuration }} --output $(Build.ArtifactStagingDirectory)/${{ variables.solutionName }}'
      zipAfterPublish: false
      modifyOutputPath: false
variables.configuration = Release
How hard can it be 😛
d
Maybe you have some funky file committed in GIT. You might be able to reproduce in that case by cloning the project in a new folder and then try to publish locally
s
Maybe the output path it not valid.. ? but it works for v14?
There is an extra
'
there in
/home/vsts/work/1/a/TestDockerDeploymentSlot'
and the first result I get on Kagi (better than Google 😉 ) is exactly that, a path with a
'
in it. https://stackoverflow.com/questions/78808252/number-of-destinationfiles-not-equal-to-sourcefiles-c-sharp-winform
l
Hey I was just looking into a similar issue: https://github.com/microsoft/azure-pipelines-tasks/issues/12829 😄
Found it.... I seriously hate working with yaml files, it so much trial and error:
Copy code
# The name (without the .sln extension) of the solution to build/publish release
solutionName: TestDockerDeploymentSlot'
Thanks for the help again! @Sebastiaan I'll buy you a beer at Codegarden 😉
s
Ha! I disregarded that stack overflow post 3 times 😆 No worries, and beer bribes always welcome! 😁 Although I drink for free at CG, so don't worry about it 😉
l
I know you do, but it's the thought that counts, right? 😄
25 Views