简体   繁体   中英

How to add tasks to azure dev ops starter?

I am new to azure dev ops and yml files. I recently created an Azure dev ops starter resource for a .NET Core site I built. I connected it to a github repo and pushed some files.

I am getting the error:

Build FAILED.

/home/runner/.dotnet/sdk/3.1.302/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v5.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application

I researched the issue and came up with this solution https://stackoverflow.com/questions/65079876/error-msb3644-the-reference-assemblies-for-framework-netframework-version-v5#:~:text=assemblies%20for%20framework%20%22.-,NETFramework%2CVersion%3Dv5.,SDK%20or%20Targeting%20Pack%20installed .

However I have no idea how to actually implement this. Do I create a separate yml file and it just fixes it when I push it to git?

I tried adding the following block to the devops-starter-workflow.yml file that was autogenerated by azure in the repo when it was auto created :

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.100'
  inputs:
    packageType: 'sdk'
    version: '5.0.100'
    includePreviewVersions: true

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'

but I got the error "every step must define a uses or run key"

How do I actually add this to my build? I dont see a pipeline anywhere in my azure portal.

Are you specifying the MS Agent vs2017-win2016

Here is an example of one I have made should help you to figure it out your error looks to me like you are using the wrong agent as it cant find Visual Studio Code to be able to build the .Net App.

 trigger: branches: include: - master pr: none pool: vmImage: vs2017-win2016 variables: System.Debug: false azureSubscription: 'AzureSub' RG: 'myrg' Location: UK South appconnectionname: 'azuresub/serviceprinciplename' jobs: - job: job1 displayName: Create And Publish Artifact steps: - task: UseDotNet@2 ## Not Needed For MS Self Hosted Agent. displayName: Use .Net Core 5.0.301 SDK inputs: packageType: 'sdk' version: '5.0.301' - task: DotNetCoreCLI@2 displayName: dotnet restore inputs: command: restore projects: 'Website.csproj' - task: DotNetCoreCLI@2 displayName: dotnet build inputs: projects: 'Website.csproj' arguments: '--configuration Release' - task: DotNetCoreCLI@2 displayName: dotnet restore unit tests inputs: command: restore projects: 'UnitTests/UnitTests.csproj' - task: DotNetCoreCLI@2 displayName: dotnet Test inputs: command: test projects: 'UnitTests/UnitTests.csproj' arguments: '--configuration Release' - task: DotNetCoreCLI@2 displayName: dotnet publish inputs: command: publish projects: 'Website.csproj' arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: true modifyOutputPath: false - task: PublishPipelineArtifact@1 displayName: Publish Pipeline Artifact inputs: targetPath: '$(Build.ArtifactStagingDirectory)' artifact: 'Website' publishLocation: 'pipeline' - job: job2 displayName: Create Web App dependsOn: job1 steps: # Download Artifact File - download: none - task: DownloadPipelineArtifact@2 displayName: 'Download Build Artifacts' inputs: patterns: '**/*.zip' path: '$(Build.ArtifactStagingDirectory)' # deploy to Azure Web App - task: AzureWebApp@1 displayName: 'Azure Web App Deploy: nsclassroom' inputs: package: $(Build.ArtifactStagingDirectory)/**/*.zip azureSubscription: $(azureSubscription) ConnectedServiceName: $(appconnectionname) appName: 'nsclassroom' ResourceGroupName: $(RG)

Please put this in a YAML formatter in Azure DevOps to just check spaces or install YML Extension in VS Code.

In the portal I created a seperate Web App and set the service to .Net version 5 instead of Core v3 and was able to build it properly. A new yml file was created and I had to just update the build and publish processes to the path with my csproj. I think all along I needed the webapp - not devops starter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM