How to resolve the following error shown while trying to build the code for Azure DevOps on Visual Studio 2022 on Windows Server 2019 - azure-devops

##[error]C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1217,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 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...

my solution was to upgrade any project targeting .Net Framework 4.5 to 4.7.2 and then building on Visual Studio 2019 instead of 2022, same Win Server 2019

I am also having this issue. Here is my (unsuccessful) progress in trying to solve it
I am also having this issue in Visual Studio 2022 Community after switching all of my solution's projects from various versions of .NET Framework to now all targeting ".NET Framework 4.8".
My error (almost identical to OP's):
C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v2.0 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 [C:\Users\MyUsername\source\repos\MyRepo1\Source\Libs\MyLibs\MyLibProject\MyLibProject.csproj]
This error mentions column 5 of line 1217 of file C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Common.CurrentVersion.targets, this leads to the part <GetReferenceAssemblyPaths of the following:
<Target
Name="GetReferenceAssemblyPaths"
DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn);GetFrameworkPaths">
...
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
...
</Target>
I understand that the parts like $(TargetFrameworkMoniker) are variables. To determine what these evaluate to, I go into Visual Studio, open the csproj file, go to "Build Events > Pre-build event command line" and type echo "TargetFrameworkMoniker" = "$(TargetFrameworkMoniker)". Then I save & build the project, ignore the errors and instead go to the window "Output" to see what these variable evaluate to. I do this for each of the variables. Below is the same code from above, but the variables are now what they actually evaluate to (for me):
<Target
Name="GetReferenceAssemblyPaths"
DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn);GetFrameworkPaths">
...
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'.NETFramework,Version=v4.8' != '' and ('' == '' or '' == '')"
TargetFrameworkMoniker=".NETFramework,Version=v4.8"
RootPath=""
TargetFrameworkFallbackSearchPaths=""
BypassFrameworkInstallChecks=""
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'' == ''"/>
</GetReferenceAssemblyPaths>
...
</Target>
I don't see anything that suggests anything other than ".NET Framework 4.8", so I am now unsure how to proceed.

I got this issue resolved by downgrading from Visual Studio 2022 to Visual Studio 2014. I uninstalled Visual Studio 2022 and installed Visual Studio 2014, and the rest fell in place. My installation is now up and running.

Changing from
vmImage: 'windows-latest'
to
vmImage: 'windows-2019'
worked for me. It used to work earlier because 2019 was latest, now the latest is 2022 and there is issue with that.
https://github.com/actions/runner-images/issues/5055

Related

There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'ios-arm64'

I was using VS Enterprise 17.3 preview 1 but my trial was expiring so I download and installed VS Community 17.3 preview 1. I open my MAUI project and build and I get this error;
There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'maccatalyst-x64
I assume I must've missed something in the installation so I go back but all the relevant components are installed
I double check with the Enterprise installation and they match. I then go back to opening the project in VS Enterprise and now I get the same error there too!?
I've tried deleting bin/obj folders cleaning and rebuilding;
I've tried adding this to the .csproj
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
I've tried changing the TargetFrameworks from this:
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
To this (and a few other combinations):
<TargetFrameworks>net6.0-android;</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
So I'm now stuck unable to build :( help pls
Turns out I had an error in a blazor file that the compiler wasn't referencing. The 'no runtime pack' error was a red herring and unrelated to the actual error.

how to call boost libraries on appveyor, how to set environment variable to run boost test successfully?

I want to run boost test in appveyor. My code can built successfully without boost test. When I run boost test, it has compile error.
Build started
2
git clone -q --branch=master https://github.com/Gaussma/StaticLibrary.git c:\projects\myproject
3
git checkout -qf 857f43f706d59e6ed74d7af6771d102850e615a0
4
msbuild "c:\projects\myproject\StaticLibrary.sln" /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
5
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
6
Copyright (C) Microsoft Corporation. All rights reserved.
7
8
LinkedListcpp.cpp
9
MathFuncsLib.cpp
10
Generating Code...
11
MathFuncsLib.vcxproj -> c:\projects\myproject\x64\Debug\MathFuncsLib.lib
12
boostTest_LinkedList.cpp
13
c:\projects\myproject\myexecrefslib\boosttest_linkedlist.cpp(3): fatal error C1083: Cannot open include file: 'boost/test/included/unit_test.hpp': No such file or directory [c:\projects\myproject\MyExecRefsLib\MyExecRefsLib.vcxproj]
Cleary, the appveyor can not find the boost library.
Locally, I am using Visual Studio 2017 and boost library 1_68_0 to generate the MyExecRefsLib.vcxproj file.
I search on the stackoverflow and find others implement the .yml file in this way.
environment:
BOOST_ROOT: C:\Libraries\boost_1_59_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0
I update it correspondingly for boost_1_67_0 since I am using Visual Studio 2017 in appveyor and boost already installed in appveyor Virtual Machine.
https://www.appveyor.com/docs/windows-images-software/#boost
environment:
BOOST_ROOT: C:\Libraries\boost_1_67_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_67_0\lib64-msvc-14.1
I do not have .yml file , I set those two the environmental variables manually in the project's setting in appveyor.
I am wondering what is the correction setting for those two environment variables to run boost test? Current setting has compile error.
Acutually, this is very easy question. We should make the build environment are same between my local machine and appveyor.
In appveyor :
environment:
BOOST_ROOT: C:\Libraries\boost_1_64_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_64_0\lib64-msvc-14.1
In Visual Studio :
Project-> Properties-> C/C++ ->General -> Additional Include Directories : C:\Libraries\boost_1_64_0
Project-> Properties->Linker -> Additional Library Dependencies : C:\Libraries\boost_1_64_0\lib64-msvc-14.1
Just move the boost_1_64_0 in the Libraries and change the library from stage_x8\lib to lib64-msvc-14.1 is OK.

Cordova app for Windows, NuGet fails to get correct version of System.Collections.Specialized

I'm tearing my hair out trying to build a windows app using Cordova. The build error I'm getting is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(377, 5):
error : The package System.Collections.Specialized with version 4.0.0
could not be found in C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\.
Run a NuGet package restore to download the package.
[C:\cygwin64\home\Owner\src\apps\mytestapp-
gen\platforms\windows\CordovaApp.Windows10.jsproj]
In visual studio, I attempt to add the version of the package to the project and I get the following error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Collections.Specialized
4.0.0'. You are trying to install this package into a project that targets
'native,Version=v0.0', but the package does not contain any assembly
references or content files that are compatible with that framework. For
more information, contact the package author.
Can anyone advise how to resolve this?
I've looked at this very old question How can I make my managed NuGet package support C++/CLI projects? but I can't find anything (particually from the VS2017 era) that helps
May be, this helps others to solve the issue:
My Visual Studio 2017 installation must obviously have been damaged when removing the Visual Studio 2015 installation from that same machine. After I performed a repair of Visual Studio 2017 via Visual Studio Installer the isuue disappeared.

Build error on Appveyor with newest ASP.NET 5

I'm trying to build an ASP.NET 5 web api and build it on Appveyor. I get this error:
Build started
git clone -q --branch=master https://github.com/nikolaschou/TodolistService01.git C:\projects\todolistservice01
git checkout -qf 3c97bb95ecf54662069b6ae8fa25a60f598a564d
msbuild "TodolistService.sln" /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
Microsoft (R) Build Engine version 14.0.24720.0
Copyright (C) Microsoft Corporation. All rights reserved.
Cannot find DNX runtime dnx-clr-win-x86.1.0.0-rc1-update1 in the folder: C:\Users\appveyor.dnx\runtimes
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(126,5): error : The Dnx Runtime package needs to be installed. See output window for more details. [C:\projects\todolistservice01\src\TodolistService\TodolistService.xproj]
Command exited with code 1
This project is based on .NET framework 4.6.1 and ASP.NET 5. The references are DNX 4.5.1 and DNX Core 5.0.
Feel free to reproduce the error by building this public repository:
https://github.com/nikolaschou/TodolistService01
Can anyone explain why it fails? Is Appveyor not yet ready for these new versions?
Basically, you have to do two things:
install .NET framework
restore packages
This is appveyor.yml to build your project:
os: Visual Studio 2015
install:
- dnvm upgrade -r clr
- dnu restore
build:
verbosity: minimal
Build results: https://ci.appveyor.com/project/FeodorFitsner/todolistservice01
Also, you may need to select right version in your global.json:
{
"sdk": {
"version": "1.0.0-rc1-final"
}
}

NuGet restore during first asp.net vNext project

Today I installed ASP.NET 5 on windows and begun creating my first application in Visual Studio 2015.
When the project loads I get an error: "Package restore failed", specifically the following error:
Restore failed Det gick inte att hitta en del av s�kv�gen C:\Users\h\.dnx\packages\Microsoft.Win32.Primitives\4.0.0\Microsoft.Win32.Primitives.4.0.0.nupkg.sha512. NuGet Config files used:
C:\Users\h\AppData\Roaming\NuGet\nuget.config
C:\Users\h\documents\visual studio 2015\Projects\NextTest\nuget.config
Feeds used:
https://api.nuget.org/v3-flatcontainer/
C:\Program Files (x86)\Microsoft Web Tools\DNU
When I look for the missing file I find the following path missing:
C:\Users\h\.dnx\packages\Microsoft.Win32.Primitives\4.0.0\Microsoft.Win32.Primitives.4.0.0.nupkg.sha512
But this one exists, note the extra 0 in the version:
C:\Users\h\.dnx\packages\Microsoft.Win32.Primitives\4.0.0.0\Microsoft.Win32.Primitives.4.0.0.0.nupkg.sha512
How would I go about to solve this?
I've tried to search through the project files but no mention of neither Primitives nor verion 4.0.0.
The "Solution DNX SDK version" is 1.0.0-beta8, (beta5 was also available but not selected).
Delete C:\Users\h.dnx\packages folder and try running "dnu restore" command.