Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows-latest missing reference assemblies for .NETFramework,Version=4.6.1 #5055

Closed
2 of 7 tasks
chriscfox opened this issue Feb 9, 2022 · 19 comments
Closed
2 of 7 tasks

Comments

@chriscfox
Copy link

Description

Azure Pipeline shows:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1217,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

on windows-latest. Reverting to windows-2019 fixes it.

I hope I am clear enough. A bit of a noob, I am afraid.

Virtual environments affected

  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11
  • Windows Server 2016
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

windows-latest versus windows-2019

Is it regression?

No response

Expected behavior

No response

Actual behavior

No response

Repro steps

  1. Set: vmImage: 'windows-latest'

The error is produced.

@shilovmaksim
Copy link
Contributor

Hi @chriscfox

Lets check whether it is sufficient to mitigate the issue by adding these components.
Could you please try to install them during runtime using following PowerShell snippet:

Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$InstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise"
$componentsToAdd = @(
  "Microsoft.Net.Component.4.6.1.SDK"
)
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " +  $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -eq 0)
{
    Write-Host "components have been successfully added"
}
else
{
    Write-Host "components were not installed"
    exit 1
}

@miketimofeev
Copy link
Contributor

@chriscfox gentle ping on this

@chriscfox
Copy link
Author

chriscfox commented Feb 12, 2022

Hi All. Apologies for the delay. I have now tried this. It fails for me with exit code 1.

Being a noob, let me elaborate by saying:

  • I added the text from the script in a file in the same directory as my yaml file
  • I added '- powershell: filePath $(Build.SourcesDirectory)\powershellscript.ps1' to my yaml file as the first step. (I tried numerous version of this, but this is the only one that the IDE would accept

@chriscfox
Copy link
Author

Strangely, my build now seems to be working with windows-latest. So I wonder if something else got fixed in the interim?

@IwryRozemberg
Copy link

I have the same problem and when trying to use the suggested solution by @shilovmaksim.

Even after installation I still get the error message.

PowerShell:

==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.198.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\4eef8efb-6e23-47c5-b0c1-4f1e986c26fe.ps1'"
components have been successfully added
Finishing: PowerShell

Build:

==============================================================================
Task         : Visual Studio build
Description  : Build with MSBuild and set the Visual Studio version property
Version      : 1.199.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [17.0,18.0) -latest -format json
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" "D:\a\1\s\SistemaVenda.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=a47fdb22-dd57-49a2-8032-e85af8bae11c|SolutionDir=D:\a\1\s|enableOrphanedProjectsLogs=true"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\1\a" /p:platform="Any CPU" /p:configuration="Release" /p:VisualStudioVersion="17.0" /p:_MSDeployUserAgent="VSTS_bdfd19a7-2e27-49d2-a000-a44800091457_build_3_0"
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 2/15/2022 3:11:48 AM.
Project "D:\a\1\s\SistemaVenda.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|Any CPU".
##[error]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1217,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

@shilovmaksim
Copy link
Contributor

Hi @chriscfox, @IwryRozemberg . Provided snippet can be executed inline. If you are calling it from the script then repo checkout should come first.
$InstallPath should be adjusted according the windows version you are running:

steps:
  - displayName: Install component on windows 2022
    pwsh: |
      Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
      $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
      $componentsToAdd = @(
        "Microsoft.Net.Component.4.6.1.SDK"
      )
      [string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " +  $_}
      $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
      $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
      if ($process.ExitCode -eq 0)
      {
          Write-Host "components have been successfully added"
      }
      else
      {
          Write-Host "components were not installed"
          exit 1
      }
steps:
  - displayName: Install component on windows 2019
    pwsh: |
      Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
      $InstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"
      $componentsToAdd = @(
        "Microsoft.Net.Component.4.6.1.SDK"
      )
      [string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " +  $_}
      $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
      $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
      if ($process.ExitCode -eq 0)
      {
          Write-Host "components have been successfully added"
      }
      else
      {
          Write-Host "components were not installed"
          exit 1
      }

@OZZlE
Copy link

OZZlE commented Feb 15, 2022

steps:
- uses: actions/checkout@v2
- name: Install component on windows 2022
  run: |
  # ...

@OZZlE
Copy link

OZZlE commented Feb 15, 2022

or "runs-on: windows-2019" ?

@miketimofeev
Copy link
Contributor

@OZZlE the issue seems to affect only windows-2022

@IwryRozemberg
Copy link

Did not work! :(
The install script ran but the build still failed!

Below is an image of the order used.:
image

@miketimofeev
Copy link
Contributor

miketimofeev commented Feb 15, 2022

@IwryRozemberg @chriscfox it turned out that VS2022 doesn't have Microsoft.Net.Component.4.6.1.TargetingPack, the minimal available version is Microsoft.Net.Component.4.6.2.TargetingPackhttps://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-enterprise?view=vs-2022. Could you try to install it in runtime and change your project to use 4.6.2 rather than 4.6.1?

      Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
      $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
      $componentsToAdd = @(
        "Microsoft.Net.Component.4.6.2.TargetingPack"
      )
      [string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " +  $_}
      $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
      $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
      if ($process.ExitCode -eq 0)
      {
          Write-Host "components have been successfully added"
      }
      else
      {
          Write-Host "components were not installed"
          exit 1
      }

@IwryRozemberg
Copy link

As a palliative solution I changed the pipeline version to windows-2019, over the weekend, I will update the .NET in the project.
@miketimofeev and @shilovmaksim, i appreciate the help.

@shilovmaksim
Copy link
Contributor

shilovmaksim commented Feb 16, 2022

Hi @chriscfox , @IwryRozemberg .
You can try to install both "SDK" along with "TargetingPack" via snippet suggested earlier to see if it helps.

$componentsToAdd = @(
    "Microsoft.Net.Component.4.6.1.SDK",
    "Microsoft .NET Framework 4.6.1 Targeting Pack"
  )

https://github.com/shilovmaksim/test-repo/runs/5213299825?check_suite_focus=true

@chriscfox
Copy link
Author

Hi @shilovmaksim and @miketimofeev . I notice you're still tagging me in your proposals. And I don't want to appear ungrateful. But as of my message of 4 days ago, my issue was resolved. I guess I should have closed the issue, but then @IwryRozemberg passengered onto it, so I though I would leave it open for them.

Anyway, I just thought I would mention this as I didn't want you to think I was being rude and ignoring your suggestions.

@miketimofeev
Copy link
Contributor

@IwryRozemberg please feel free to open a new issue.

@OZZlE
Copy link

OZZlE commented Feb 18, 2022

@OZZlE the issue seems to affect only windows-2022

Yes but "windows-latest" used to be Windows 2019 and we didn't notice that Github changed to 2022. Our code is made for 2019 and we have that on our servers so makes sense for us to just change. Probably never should have had latest, very future inconsiderate :P

@AF250329
Copy link

Yes - that's right. When windows-latest was changed to Windows 2022, the error began to occur. I don't know what changed at Windows 2022 but compilation fails with error Error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found..

It appears that changing the Github action runner to runs-on: windows-2019 resolves the issue.

@chriscfox
Copy link
Author

I know this makes no sense, but my experience was:

  1. I had runs-on: windows-latest
  2. Then GitHub changed to windows 2022 and I started getting Error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found.
  3. I changed my script to runs-on: windows-2019 and it worked again.
  4. Then I changed it back to runs-on: windows-latest and it STILL WORKS - no error.

That last step makes no sense and I can't explain it. I can only relate my experience. Did something else also happen? I don't know.

.

@catthehacker
Copy link
Contributor

That last step makes no sense and I can't explain it. I can only relate my experience. Did something else also happen? I don't know.

It's because windows-latest is migrating from windows-2019 to windows-2022
#4856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants