I'm running into this issue when I try to run dotnet publish in Azure Devops. It fails with the following error:
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
C:\hostedtoolcache\windows\dotnet\dotnet.exe publish D:\a\1\s\src\COMPASSDataIngestion\COMPASSDataIngestion.csproj -o D:\a\1\a\COMPASSDataIngestion -c Release
MSBuild version 17.3.2+561848881 for .NET
Determining projects to restore...
Restored D:\a\1\s\src\COMPASSDataIngestion\COMPASSDataIngestion.csproj (in 1.65 min).
D:\a\1\s\src\COMPASSDataIngestion\Functions\SB1Parser.cs(236,36): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [D:\a\1\s\src\COMPASSDataIngestion\COMPASSDataIngestion.csproj]
C:\hostedtoolcache\windows\dotnet\sdk\6.0.408\Microsoft.Common.CurrentVersion.targets(5097,5): error MSB3030: Could not copy the file "D:\a\1\s\src\COMPASSDataIngestion\local.settings.json" because it was not found. [D:\a\1\s\src\COMPASSDataIngestion\COMPASSDataIngestion.csproj]
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
C:\hostedtoolcache\windows\dotnet\dotnet.exe publish D:\a\1\s\src\S00PackageRun\S00PackageRun.csproj -o D:\a\1\a\S00PackageRun -c Release
MSBuild version 17.3.2+561848881 for .NET
Determining projects to restore...
Restored D:\a\1\s\src\S00PackageRun\S00PackageRun.csproj (in 2.93 sec).
C:\hostedtoolcache\windows\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(190,5): error NETSDK1022: Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'Controllers\SeatPackageController.cs'; 'Core\Application\MSOffice\IExcelWriter.cs'; 'Core\Application\Storage\BlobDto.cs'; 'Core\Application\Storage\BlobResponseDto.cs'; 'Core\Application\Storage\IStorageService.cs'; 'Infrastructure\Data\SqlService.cs'; 'Infrastructure\Data\Startup.cs'; 'Infrastructure\MicrosoftOffice\MicrosoftExcelService.cs'; 'Infrastructure\MicrosoftOffice\MicrosoftWordService.cs'; 'Infrastructure\MicrosoftOffice\Startup.cs'; 'Infrastructure\Middleware\ErrorResult.cs'; 'Infrastructure\Middleware\ExceptionMiddleware.cs'; 'Infrastructure\Middleware\Startup.cs'; 'Infrastructure\Services\DirectoryService.cs'; 'Infrastructure\Services\EMCDTemplateService.cs'; 'Infrastructure\Services\PackageSummaryTemplateService.cs'; 'Infrastructure\Services\SB1PackageReportTemplateService.cs'; 'Infrastructure\Services\Startup.cs'; 'Infrastructure\Services\TemplateServiceBase.cs'; 'Infrastructure\Startup.cs'; 'Infrastructure\Storage\BlobService.cs'; 'Infrastructure\Storage\Startup.cs'; 'Models\Compass\ExcelMappingFieldAttribute.cs'; 'Models\Compass\SB1PackageReportData.cs'; 'Models\Compass\TSOTransmittalData.cs'; 'Models\Configurations\AppSettingsConfiguration.cs'; 'Models\Configurations\AzureConfiguration.cs'; 'Models\Configurations\ConnectionStringsConfiguration.cs'; 'Models\Configurations\Startup.cs'; 'Models\PackageCriteria.cs'; 'Models\PackageStatistics.cs'; 'Models\WordTemplateField.cs'; 'Program.cs' [D:\a\1\s\src\S00PackageRun\S00PackageRun.csproj]
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : [
'D:\\a\\1\\s\\src\\COMPASSDataIngestion\\COMPASSDataIngestion.csproj',
'D:\\a\\1\\s\\src\\S00PackageRun\\S00PackageRun.csproj'
]
Finishing: Dotnet publish
For some reason the separate classes and functions are being included as Compile items and causing this issue. I can't delete the separate compile items because it seems to dereference them in the project file and are no longer linked. I didn't use to run into this issue before and need some guidance on this.
I am also pasting my pipeline code below, but it has worked on other project files without the compile items:
parameters:
I'm running into this issue when I try to run dotnet publish in Azure Devops. It fails with the following error:
I've pasted below my project file.
For some reason the separate classes and functions are being included as Compile items and causing this issue. I can't delete the separate compile items because it seems to dereference them in the project file and are no longer linked. I didn't use to run into this issue before and need some guidance on this.
I am also pasting my pipeline code below, but it has worked on other project files without the compile items: parameters: