4
votes

I am new to DevOps and CICD pipelines.
I successfully deployed ASP .NET MVC website using Azure DevOps CICD pipeline to my onprem agent/machine using Azure DevOps.

Similarly I want to deploy a console application which can be ultimately used as scheduled job in windows 'Task Scheduler' or either as a 'Windows Service'. Right now I am managing these deployments manually but after seeing the power of DevOps I hope, there could be really some automated solution for console apps as well.

The applications are built in legacy framework like 3.5 to 4.5, so not .net core apps. I found lot of online articles which demonstrates deploying webjobs on azure or may be possible for onprem but is it possible for old console apps?

I tried to build a very simple console app in Framework 4.7 and tried to deploy/copy/publish to my onprem machine's shared path. Gave permission to VSTS agent services which are running but copy files and publish artifact tasks are failing. I tried to do it in both CI and CD pipelines but all are failing.

Please review the pipelines and logs and suggest where I am doing wrong or there are any alternatives?
https://dev.azure.com/MSTCsandippatel/DemoConsoleApp

2019-11-05T05:03:52.8436105Z ##[error]Publishing build artifacts failed with an error: Unable to create directory '\MAHANTAM\Azure Artifacts\DemoConsoleApp'. Unable to verify the directory exists: '\MAHANTAM\Azure Artifacts\DemoConsoleApp'. If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.

CI pipeline 1

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- 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: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'DemoConsoleApp'
    publishLocation: 'Container'
trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- 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: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'DemoConsoleApp'
    publishLocation: 'Container'

CI pipeline 2

pool:
  name: Azure Pipelines
  demands:
  - msbuild
  - visualstudio

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'
    vstsFeed: '622d44e2-69d4-4d42-bb91-9d6ddd97f9ba/8eaf9077-829d-4567-93c0-8e0d7973634b'

- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    solution: '$(Parameters.solution)'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)'
    Contents: '**\bin\$(BuildConfiguration)\**'
    TargetFolder: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

- task: CopyFiles@2
  displayName: 'Copy Files Task'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)'
    Contents: '**/**'
    TargetFolder: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

- task: ArchiveFiles@2
  displayName: 'Archive $(Build.BinariesDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: DemoConsoleApp'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: DemoConsoleApp

enter image description here

Deployment group - machine

1
Failing with what error? If you are deploying on-prem, it's probably easier to provision an on-premise Deployment AgentNick.McDermaid
I accessed your DevOps and captured the error. (BTW You linked to the wrong area) It looks like a normal access error. Can you explain what the deploy step does / is as we don't have access.Nick.McDermaid
Thanks for your comment @Nick.McDermaid. This is for learning purpose only where I am trying to figure out how to setup CICD for console apps. Ultimately I have to deploy it on multiple servers where there is already setup of scheduled jobs and win services. In deployment I just need to copy the bin folder to uat/prod server. Copy exe+config +dlls which I do manually every time currently.sapatelbaps
Are you using Hosted Azure Pipelines? This is a cloud machine that is not going to have access to your shared drive. Or are you using a self hosted agent?Nick.McDermaid
I tried to change parameters in CD pipeline image above but no luck. I am using 'Deployment groups' option where my machine is registered, seems online and where I deployed the MVC webapp as well.sapatelbaps

1 Answers

1
votes

If you use Agent Pool "Azure Pipelines" for your agent, the deployment will occur on an azure cloud machine which doesn't know anything about your on-premise machines.

enter image description here

You should install a self-hosted agent on-premise and link that to your DevOps and use that for the agent.

https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops