I have a solution with target framework of 4.7.1. I have locally installed dotnet core sdks and able to issue build, publish commands.
My project file looks like this, with many references to dotnet core dlls
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.3.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.4.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0">
I have errors in Azure DevOps yaml while trying to use a specific .net sdk to build this solution.
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '2.x'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
workingDirectory: '$(solution)'
The error reads There was an error when attempting to execute the process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'. This may indicate the process failed to start. Error: spawn C:\hostedtoolcache\windows\dotnet\dotnet.exe
More importantly, I am not sure which dotnet core version should I use to build this project?
Locally, I have dotnet 5 sdk and able to publish successfully using dotnet publish commands. What commands should I ideally use in DevOps to build a net471 project?
Thanks, AK
.NET Core is different as compared to .NET Framework.
Moreover, if you want to create a pipeline for your .NET Framework project, you cannot use .NET Core tasks. Your YAML
file of Pipeline
should look like below:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- master
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
inputs:
PathtoPublish: $(build.artifactstagingdirectory)
ArtifactName: 'PublishBuildArtifacts'
Refer a step-by-step tutorial for this here.