MiroslavDinev
MiroslavDinev

Reputation: 1

Azure DevOps build pipeline for ASP NET Core WebService project (.NET 6 + .NET Framework 4.8)

I have the task to configure Azure DevOps build pipeline for ASP NET project. It is a legacy solution using WCF and WPF with many projects inside it.

The Service layer and the Repository layer + most of the other projects in the solution are targeting .NET Framework 4.8 and .NET Standard 2.0 Class Library. Recently we added WebService (.NET Core 6 WEB API) using the existing services, repos, etc.

Currently I am trying to setup Azure DevOps build pipeline for the above mentioned WebService project but unfortunately the build phase always fails. The strange thing is that some of the projects are build properly (.NET Framework 4.8) but some of them fail with error saying:
"Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore" and there is no option to add RuntimeIdentifiers to .NET Framework as it is made to run on windows anyways.

As I have no experience in DevOps at all believe there is something wrong with my setup.

Has anybody had similar setup and how it managed to make it work. All help will be appreciated, thanks.

enter image description here

UPDATE: It seems the solution of problem was quite unexpected. In the NuGet Restore task I had to state **/sln instead of the specific WebProject.csproj in this case. With this small change the pipeline passed successfully. Thanks everyone for the suggestions.

Upvotes: 0

Views: 665

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13444

If the legacy WCF and WPF Class Library projects (.NET Framework 4.8 and .NET Standard 2.0) are not needed to build and not the dependencies of the WebService project (.NET Core 6), you can directly use the .NET Core task to build the WebService project without extra steps before it. The Microsoft-hosted windows-latest agent has the new.NET 6 SDK preinstalled as the default .NET version.

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: xxxx.WebService.csproj
    arguments: '-c $(BuildConfiguration)'

enter image description here


If you also need to build the legacy WCF and WPF Class Library projects, on the windows-latest agent, the preinstalled oldest .NET version is .NET Framework: 4.8. No .NET Standard 2.0 installed.

You need to try to use the command lines to download and install .NET Standard 2.0 on the agent. But it may be not possible to guarantee the .NET Standard 2.0 can be installed successfully on the windows-latest agent due to possible compatibility issues.

Upvotes: 1

Related Questions