Azure Devops can an ASP.NET Core 8 Web API be built with .NET Framework references?

I have an ASP.NET Core 8 Web API that I am building/deploying through Azure Devops. The API is being hosted in IIS on a server, so I was using the DotNetCoreCLI@2 task to perform a dotnet publish which would build my project and generate a web.config.

I have some legacy .NET 4.8 projects that are now included in the project references and this has broken my build process. When trying to do the same build I would get an error:

The task “SGen” is not supported on the .NET Core version of MSBuild

It looked like this had to do with XML serialization in the legacy projects, although none of them explicitly had:

<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>

I think that one solution would be to add to all legacy projects:

<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>

but I would like to avoid that. In order to successfully build my ASP.NET Core 8 Web API + legacy references I had to swap to the VSBuild@1 task which looks like:

- task: VSBuild@1
    inputs:
      solution: ./MyApi/MyApi.csproj
      msbuildArgs: '/p:OutputPath=$(publishDirectory)'
      configuration: 'Release'
      platform: Any CPU  

This works fine, except we no longer would have the web.config being generated. My thought was that I could add a step following this that would still utilize the the DotNetCoreCLI@2 task and pass it the argument

--no-build

since I have already built the project. Now I get this error:

Microsoft.NET.Sdk.StaticWebAssets.References.targets: error : Manifest files at ‘objReleasenet8.0staticwebassets.build.json’ not found

So I don’t think I can go with a no build route. My last hope was to build only my ASP.NET Core 8 Web API since I have built all of the legacy dependencies and that would generate the web.config. In my DotNetCoreCLI@2 task I tried passing

/p:BuildProjectReferences=false

as an argument, but it cannot find any of the legacy files and errors out. It appears that the dotnet publish step is meant to be a standalone, do-it-all process?

The only solutions I can think of are:

  1. Manually add web.config to my solution and maintain it (probably the easiest?)
  2. Explicitly set serialization off in all legacy .csproj

Is there any possible option in my build process to achieve what was happening before?

6

I attempted with a sample as below, and everything can work fine:

  1. The projects within the same solution (.sln).

    • The .NET 8 Web API project. It has a project reference.
    • The .NET Framework 4.8 project referenced by the .NET 8 Web API project.
  2. The sample of the pipeline.

    steps:
    # Restore the required NuGet packages for all projects.
    - task: NuGetCommand@2
      displayName: 'NuGet restore'
    
    # Run 'dotnet publish' for the Web API project.
    # Set output directory as '$(Build.ArtifactStagingDirectory)'.
    - task: DotNetCoreCLI@2
      displayName: 'dotnet publish'
      inputs:
        command: publish
        publishWebProjects: false
        projects: myWebAPI/myWebAPI.csproj
        arguments: '--no-restore -c Release -o $(Build.ArtifactStagingDirectory)'
        zipAfterPublish: false
    
    # Publish the output artifact files from the directory '$(Build.ArtifactStagingDirectory)' to Azure Pipelines.
    - task: PublishPipelineArtifact@1
      displayName: 'Publish Pipeline Artifact'
      inputs:
        targetPath: '$(Build.ArtifactStagingDirectory)'
        artifact: drop
    
  3. Result.


EDIT:

I can reproduce the same error if I add the property “<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>” to the .csproj file of the project reference, and only use the DotNetCoreCLI@2 task to build the project.

When building the .NET 8 project, by default it also will build all of its project references together. The error occurs when using the dotnet command to build the .NET Framework 4.8 project references that the “GenerateSerializationAssemblies” is set to “On“.

To avoid the error, you can do like as below:

  1. Use the VSBuild@1 task to build the .NET Framework 4.8 project references.

  2. Then use the DotNetCoreCLI@2 task to build .NET 8 project. On this task, add the MSBuild project property “-p:BuildProjectReferences=false” as an argument to skip building the project references as they have been built by previous VSBuild@1 task. See “Common MSBuild project properties“.

Below is a sample of the pipeline as reference.

steps:
- task: NuGetCommand@2
  displayName: 'NuGet restore'

- task: VSBuild@1
  displayName: 'Build - myConsoleApp'
  inputs:
    solution: myConsoleApp/myConsoleApp.csproj
    configuration: Release
    msbuildArchitecture: x64

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish - myWebAPI'
  inputs:
    command: publish
    publishWebProjects: false
    projects: myWebAPI/myWebAPI.csproj
    arguments: '--no-restore -c Release -o $(Build.ArtifactStagingDirectory) -p:BuildProjectReferences=false'
    zipAfterPublish: false

- task: PublishPipelineArtifact@1
  displayName: 'Publish Pipeline Artifact'
  inputs:
    targetPath: '$(Build.ArtifactStagingDirectory)'
    artifact: drop


2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật