admin管理员组

文章数量:1410724

We have a project that we've been building locally for months, with no issue, and in Azure DevOps with success until just recently. It is a DotNet MAUI application, which has multiple projects within one large solution. One of the projects is a demo application which makes use of the other projects. Generally, we run one build command, and that command takes care of the entire build:

dotnet publish <PATH_TO_PROJECT> -f net8.0-windows10.0.22000.0 -c Release --self-contained true

However, when running the same command in Azure Devops, we see the following errors:

C:\Users\VssAdministrator\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\Microsoft.Build.Msix.Packaging.targets(1532,5):
error APPX1101:
Payload contains two or more files with the same destination path ‘<SUB_PROJECT>.dll'.
Source files: [D:\a\1\s\<MAIN_PROJECT>\<MAIN_PROJECT>.csproj::TargetFramework=net8.0-windows10.0.22000.0]

C:\Users\VssAdministrator\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\Microsoft.Build.Msix.Packaging.targets(1532,5):
error APPX1101:
D:\a\1\s\<SUB_PROJECT>\bin\Release\net8.0-windows10.0.22000.0\<SUB_PROJECT>dll
[D:\a\1\s\<MAIN_PROJECT>\<MAIN_PROJECT>.csproj::TargetFramework=net8.0-windows10.0.22000.0]

C:\Users\VssAdministrator\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\Microsoft.Build.Msix.Packaging.targets(1532,5):
error APPX1101:
D:\a\1\s\<MAIN_PROJECT>\obj\Release\net8.0-windows10.0.22000.0\win10-x64\R2R\<SUB_PROJECT>.dll
[D:\a\1\s\<MAIN_PROJECT>\<MAIN_PROJECT>.csproj::TargetFramework=net8.0-windows10.0.22000.0]

In other words, it is as if the .dll for the underlying project is being generated twice, when triggering a build of the overall project.

I am completely unknowing of what may be causing this; the pipeline was running just fine one day and this issue seemed to pop up out of nowhere- any thoughts are welcome.

I also attempted to build the underlying project as a Nuget package and pull it in separately, but the application did not succeed post-install with this setup (though the build did in fact work).

Edit #1: Here is some additional detail about our pipeline:

- job: BuildApp_Windows
pool:
  vmImage: 'windows-2022'
  demands:
    - MSBuild
steps:

# Set DotNet Version
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '9.0.100'

# Authenticate to Azure Artifacts
- task: NuGetAuthenticate@1

# JDK 11 is Required
- task: JavaToolInstaller@0
  inputs:
    versionSpec: '11'
    jdkArchitectureOption: 'x64'
    jdkSourceOption: 'PreInstalled'

# MAUI Install
- task: PowerShell@2
  displayName: Install .NET MAUI
  inputs:
    targetType: 'inline'
    script: |
      & dotnet nuget locals all --clear
      & dotnet workload install maui --source .json --source .json
      & dotnet workload install android maui wasm-tools --source .json --source .json

# Restore Nuget Packages
- task: Bash@3
  displayName: Restore Nuget Packages
  inputs:
    targetType: 'inline'
    script: |
      dotnet restore <SOLUTION NAME>.sln

# Build MSIX (Unsigned)
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      dotnet publish ./$(PathToProject)/<PROJECT NAME>.csproj -f net8.0-windows10.0.22000.0 -c Release --self-contained true

Edit #2: Here is an additional build command which I have tried; removing the above bash command for DotNetCLI@2

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: ./$(PathToProject)/<MAIN_PROJECT>.csproj
    arguments: '--configuration Release --self-contained true -f net8.0-windows10.0.22000.0'

Edit #3: For clarity, the issue is specific to the build step. There is one project (referred to as MAIN_PROJECT) and another (SUB_PROJECT). In the MAIN_PROJECT.csproj, there is an item group that refers to the sub, like so:

<ItemGroup>     
<ProjectReference Include="..\<SUB_PROJECT>\<SUB_PROJECT>.csproj"/>   
</ItemGroup>

When a build is run, both the MAIN and SUB project are restored. Then, the .dll file is built at the following location:

D:\a\1\s\<SUB_PROJECT>\bin\Release\net8.0-windows10.0.22000.0\<SUB_PROJECT>.dll

Once that is done, the MAIN_PROJECT begins to build, and is located at:

D:\a\1\s\<MAIN_PROJECT>\bin\Release\net8.0-windows10.0.22000.0\win10-x64\<MAIN_PROJECT>.dll

However, it then errors, stating that the SUB_PROJECT.dll is duplicated. Along with the first location above, it is also present at:

D:\a\1\s\<MAIN_PROJECT>\obj\Release\net8.0-windows10.0.22000.0\win10-x64\R2R\<SUB_PROJECT>.dll

Which causes the error. It is if the SUB_PROJECT.dll is being placed in its own bin directory, and the obj directory of the MAIN_PROJECT.

本文标签: netAzure DevOps Pipeline Build IssueDuplicate Destination PathsStack Overflow