actions / runner-images

GitHub Actions runner images
MIT License
9.39k stars 2.91k forks source link

Unable to build in Azure Devops pipeline using agent specification windows-2019, before the code was building fine using agent VS2017-win2016 #6208

Closed ShipraRay150 closed 1 year ago

ShipraRay150 commented 1 year ago

Description

Unable to build in Azure Devops pipeline using agent specification windows-2019, before the code was building fine using agent VS2017-win2016(which is decommissioned now)

My VS .net solution is building fine using VS2019 in my local machine but it fails in Azure Devops pipeline using windows-2019 agent. In my local i had to add one environment variable : MSBuild with below path C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin

The solution in pipeline was building fine when agent specification used wasVS2017-win2016(which is decommissioned now).

Please help on this.

Platforms affected

Virtual environments affected

Image version and build link

As this is Company's build i cant share in public.

Is it regression?

yes local development

Expected behavior

The Azure devops pipeline build should be successful using agent-specification windows-2019

Actual behavior

Unable to build in Azure Devops pipeline using agent specification windows-2019, before the code was building fine using agent VS2017-win2016

Repro steps

Unable to build in Azure Devops pipeline using agent specification windows-2019, before the code was building fine using agent VS2017-win2016(which is decommissioned now)

My VS .net solution is building fine using VS2019 in my local machine but it fails in Azure Devops pipeline using windows-2019 agent. In my local i had to add one environment variable : MSBuild with below path C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin

The solution in pipeline was building fine when agent specification used wasVS2017-win2016(which is decommissioned now).

Please help on this.

al-cheb commented 1 year ago

Hey @ShipraRay150. Please add minimal repro steps with a repo how to reproduce the issue.

ShipraRay150 commented 1 year ago

Sorry i cannot share the repo as it is a organizations so cant share in public. Issue: In Azure devops pipeline my .Net framework 4.6 toolversion = 14 was building fine when agent specification used VS2017-win 2016(which is deprecated now). My organization solution is using Fake library to build the solution

But when agent specification used windows-2019 , build is failing at soln.fsx(Fake build script). (After analyzing the fake build script found 'Fake.DotNet.MSBuild.run' not able to pick the 2019 msbuild) which was completely working fine when agent specification used VS2017-win 2016. Please help!

ShipraRay150 commented 1 year ago

I am not able to check the vs2017-win2016(i donot see the link is visible to check software in msdn as this is deprecated) software links to validate which software is missing that needs to be installed in windows 2019

miketimofeev commented 1 year ago

@ShipraRay150 the latest windows-2016 readme is available by this link, you can compare the difference https://github.com/actions/runner-images/blob/493f3c3ee19fc6f2f5456b1f8563f77f0096c3e1/images/win/Windows2016-Readme.md

ShipraRay150 commented 1 year ago

In my local i am able to build the solution but in Azure Devops Pipeline it is failing.

In my local i have VS2019, but in environment variable i have added: MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin

ShipraRay150 commented 1 year ago

Please help on this!

ShipraRay150 commented 1 year ago

@miketimofeev @al-cheb Any suggestions on this issue?

al-cheb commented 1 year ago

@miketimofeev @al-cheb Any suggestions on this issue?

We can't investigate without repro steps.

ShipraRay150 commented 1 year ago

@al-cheb
Reproducing steps:

1.In Azure devops pipeline my .Net framework 4.6 toolversion = 14 was building fine when agent specification used VS2017-win 2016(which is deprecated now). My organization solution is using Fake library to build the solution

2.But when agent specification used windows-2019 , build is failing at soln.fsx(Fake build script). (After analyzing the fake build script found 'Fake.DotNet.MSBuild.run' not able to pick the 2019 msbuild) which was completely working fine when agent specification used VS2017-win 2016.

ShipraRay150 commented 1 year ago

@al-cheb @miketimofeev AzureDevops Pipeline fail error When selected Pool: [Azure Pipelines] Image: windows-2019

MSBuild Path taken by fake build script is : c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

Expected Behaviour: MSBuild path should be C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin

Details of MSBuild path in Azure devops when the fake build script was successful: When selected Pool: [Azure Pipelines] Image: VS2017-win16(which is deprecated by microsoft now)

MSBuild path taken by fake build script is : C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe

ShipraRay150 commented 1 year ago

@al-cheb @miketimofeev

Please help on this.

al-cheb commented 1 year ago

@ShipraRay150, try to add a step:

image

steps:
- task: BatchScript@1
  displayName: 'Run script C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
  inputs:
    filename: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
    arguments: x64
    modifyEnvironment: true
ShipraRay150 commented 1 year ago

@al-cheb I have one task to execute the Fake build script.

Do i need to add this Batch script before the Fake build script task ?

al-cheb commented 1 year ago

@ShipraRay150, before the Fake build task.

ShipraRay150 commented 1 year ago

@al-cheb

Tried but this didnot worked.

MSBuild Path taken: c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

al-cheb commented 1 year ago

@ShipraRay150, please attach build logs.

al-cheb commented 1 year ago

ToolPath should be an exe file, like: let msBuildPath ="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"

ShipraRay150 commented 1 year ago

ToolPath should be an exe file, like: let msBuildPath ="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"

tried with this also not worked, for some reason fake build is still taking MSbuild path as: c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

ShipraRay150 commented 1 year ago

@al-cheb

Is it possible to add an MSBuild environment variable for this agent windows-2019 in microsoft servers path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin ?

al-cheb commented 1 year ago

You can add a step to set this variable:

- pwsh: 'Write-Host "##vso[task.setvariable variable=MSBuild]C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"'
  displayName: 'Set env var'
ShipraRay150 commented 1 year ago

You can add a step to set this variable:

- pwsh: 'Write-Host "##vso[task.setvariable variable=MSBuild]C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"'
  displayName: 'Set env var'

How to add this ?

al-cheb commented 1 year ago

You can add a step to set this variable:

- pwsh: 'Write-Host "##vso[task.setvariable variable=MSBuild]C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"'
  displayName: 'Set env var'

How to add this ?

Click Add a task -> Choose PowerShell: image

ShipraRay150 commented 1 year ago

@al-cheb

Thankyou !! this worked setting the env variable.Build is success now.

ShipraRay150 commented 1 year ago

@al-cheb

My classic build pipeline is working fine but when i ran release pipeline using agent windows-2019 i get this error from Solution\AssemblyVersion.cs: error CS7034: The specified version string does not conform to the required format - major[.minor[.build[.revision]]]

Can you please help on this??

al-cheb commented 1 year ago

@ShipraRay150, please share the AssemblyVersion.cs content.

ShipraRay150 commented 1 year ago

@al-cheb Before the last successful ran with the release pipeline when agent selected was VS2017-win16

I get this error with agent windows-2019

al-cheb commented 1 year ago

@ShipraRay150, do you have a SolutionInfo.cs file?

ShipraRay150 commented 1 year ago

@ShipraRay150, do you have a SolutionInfo.cs file?

@al-cheb No we dont have

ShipraRay150 commented 1 year ago

@al-cheb Any suggestions on this please?

al-cheb commented 1 year ago

@ShipraRay150, please attach logs of the failed build. image

al-cheb commented 1 year ago

@ShipraRay150, Please show TEST.build.Constants.csproj content.

al-cheb commented 1 year ago

@ShipraRay150, from previous log you passed 2021.9.1646096.1 version. Could you replace the Build part to less than 65535 ( 2021.9.164.1) ?

ShipraRay150 commented 1 year ago

@ShipraRay150, from previous log you passed 2021.9.1646096.1 version. Could you replace the Build part to less than 65535 ( 2021.9.164.1) ?

sure will do and check

ShipraRay150 commented 1 year ago

@ShipraRay150, from previous log you passed 2021.9.1646096.1 version. Could you replace the Build part to less than 65535 ( 2021.9.164.1) ?

sure will do and check

This worked Thankyou..!! (y)

ShipraRay150 commented 1 year ago

@al-cheb, Hi need one help is there any azure devops pipeline task to copy remote server files to local machine? Please help!

al-cheb commented 1 year ago

@al-cheb, Hi need one help is there any azure devops pipeline task to copy remote server files to local machine? Please help!

You can publish an artifact and download it manually to the local machine. How to publish artifacts - https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=classic#publish-artifacts

ShipraRay150 commented 1 year ago

@al-cheb, Hi need one help is there any azure devops pipeline task to copy remote server files to local machine? Please help!

You can publish an artifact and download it manually to the local machine. How to publish artifacts - https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=classic#publish-artifacts

@al-cheb my requirement like - i want to fetch some certificates from server to my local machine.how can i do that?

al-cheb commented 1 year ago

@al-cheb, Hi need one help is there any azure devops pipeline task to copy remote server files to local machine? Please help!

You can publish an artifact and download it manually to the local machine. How to publish artifacts - https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=classic#publish-artifacts

@al-cheb my requirement like - i want to fetch some certificates from server to my local machine.how can i do that?

Please read message above how to publish artifacts.