Brand new CLR Class Library project won't build: missing MSCOREE.lib - c++-cli

Using the latest Visual Studio 2019 version, a brand new project will not build:
fatal error LNK1104: cannot open file 'MSCOREE.lib'
I have tried to re-install Visual Studio but that didn't change anything unfortunately.
These components have been selected by the installer but apparently it's not enough:
MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.24)
Windows 10 SDK (10.0.18362.0)
C++/CLI support for v142 build tools (14.24)
Question:
Are there any tricks to get CLR Class Library (.NET Framework) projects to build ?

Here is the solution:
Apparently, no matter what framework version you will target, the $(NETFXKitsDir)Lib\um\x86 macro will always point to C:\Program Files (x86)\Windows Kits\NETFXSDK\4.7.2\lib\um\x86.
Now here's the problem, even though you install 4.7.2 SDK in Visual Studio Installer, this file is nowhere to be seen.
But if you download .NET Framework 4.7.2 Developer Pack Offline Installer and press the Repair button, it gets correctly installed and a brand new project will build succesfully.
Alternatively:
Re-installing VS also fixes the issue ...

Related

Building a net40 project in VisualStudio 2022

A Windows update trashed my computer so I've had to reinstall from scratch.
We have some projects that multi-target net40
<TargetFrameworks>net40;net6.0</TargetFrameworks>
which were building just fine (and they build in the Azure pipeline) but now I can't get them to build locally.
My old machine was originally win10 with VisualStudio 2017, 2019, and 2022, but so far on the rebuilt machine I only have 2022.
The projects won't build, saying
error MSB3644: The reference assemblies for .NETFramework,Version=v4.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
I guess this means I have to install an SDK pack?
I've tried 4.6.2 and 4.6.1 which are available through the VisualStudio installer, and 4.5 (NDP452-KB2901951-x86-x64-DevPack.exe from https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net452-developer-pack-offline-installer) which is not, and Windows SDK for Windows 7 and .NET Framework 4 from https://developer.microsoft.com/en-gb/windows/downloads/sdk-archive/
but still no joy.
Any idea what I need to do to get it to build again?
The solution seems to be to install VisualStudio2017 with net40.

Visual Studio 2022 does not find reference assemblies for >NETframework Version 4.0

Trying to compile Python Django project but receiving build error:
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.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
Done building project "myFinancialTracker.pyproj" -- FAILED.
How can I resolve?
I also got the same error as you, this is because VS 2022 doesn't come with
.net framework 4.0 option during installation, to overcome this problem I install VS 2019 and enable the usage of .net-framework 4.0 during installation. After the installation, I tried to run my project again using VS2022 and the error goes away.
I tried to download and install .net-framework 4.0 separately but Microsoft doesn't allow me to do so, to overcome this, I install VS2019 instead.

Task could not find "AxImp.exe" when building project on Visual Studio Mac

I have a .net project that was built on Visual Studio PC and now I'm trying to build the project on my Mac version of Visual Studio but the project will not build.
I've reinstalled VC Mac and also installed dotnet-sdk-2.2.107-osx-x64 as well as MonoFramework-MDK-5.20.1.19.macos10.xamarin.universal
This is build error I get.
/Library/Frameworks/Mono.framework/Versions/5.20.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5):
Error MSB3086: Task could not find "AxImp.exe" using the SdkToolsPath
"/Library/Frameworks/Mono.framework/Versions/5.20.1/lib/mono/4.5/" or
the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\NETFXSDK\4.7.2\WinSDK-NetFx40Tools-x86". Make sure the
SdkToolsPath is set and the tool exists in the correct processor
specific location under the SdkToolsPath and that the Microsoft
Windows SDK is installed (MSB3086)

How to open dotnet-core CLI project in Visual Studio 2017

I have been developing a simple application using dotnet Core (for an API) and Angular2 for the purpose of learning both.
I created the project using Yeoman on the command line and have been happily coding away in Visual Studio Code (on Windows). All seems to hang together well and it's been an enjoyable experience.
I thought I might try out Visual Studio 2017 and see what the experience of developing a dotnet Core project in VS is like for a while.
However, having installed VS2017 and cloned the project from github I am unsure how to proceed. I can't see any way to restore/build/run the project.
After cloning the repo, I see my project displayed in the Solution Explorer with the project.json file visible. However, Debug | Start is greyed out. I read somewhere about VS2017 needing to convert project.json to the new (old?) XML format and also I have a feeling I am missing a .sln file.
I would appreciate it if someone could point me in the right direction.
If your project has an .xproj file
Open Visual Studio.
File > Open > Project/Solution.
Open the xxx.xproj for your solution.
If your project lacks an .xproj file
Install .NET Core SDK Preview 3 or higher.
Open a command prompt at your project's directory.
Run dotnet migrate.
Open the resulting .csproj in Visual Studio 2017.
Troubleshooting
View migration help with dotnet migrate -h.
If you have a global.json file, update its SDK version before running migrate. E.g.
{
"sdk": {
"version": "1.0.0-preview4-004233"
}
}
View installed SDK versions with dir 'C:\Program Files\dotnet\sdk\'.
Update Visual Studio 2017 and its installer. On my machine, the above works with Microsoft Visual Studio Community 2017 RC Version 15.0.26014.0 D15REL.
Update .NET Core SDK. On my machine, the above works with SDK 1.0.0-preview4-004233.

WIX And NAnt : Unable to build WIX source code

I am trying my hands on source code of WIX 3.6 to debug something as well as learn something.
On executing make.bat (present in root folder of WIX source) file, first i got NAnt not found. So I downloaded NAnt and updated make.bat file. On executing the file again I am getting this error
NAnt 0.91 (Build 0.91.3881.0; alpha2; 8/17/2010)
Copyright (C) 2001-2010 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///D:/wix36-sources/wix.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: inc
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
[property] Target framework changed to "Microsoft .NET Framework 2.0".
[property] Read-only property "dir.hhw" cannot be overwritten.
[property] Read-only property "hhw-found" cannot be overwritten.
BUILD FAILED - 2 non-fatal error(s), 2 warning(s)
D:\wix36-sources\wix.build(65,4):
Build file 'D:\wix36-sources\test\wixtests.build' does not exist.
I have .Net framework 4.0 installed on my local. Also I searched through registry for the registry key mentioned in the error and didn't found. Am I using right version of NAnt?
Do you have all of the prerequisites as described in the documentation?
In order to fully build WiX, you must have the following Frameworks and SDKs installed:
NAnt (0.90 or later)
The following components from the Windows SDK for Windows Server 2008 and .NET Framework 3.5, Visual Studio 2008, Microsoft Windows 7 SDK, and/or Visual Studio 2010:
x86 and x64 compilers, headers and libraries
IA64 headers and libraries are optional, but they are necessary for IA64 custom action support
If you want to be able to build optimized IA64 binaries, you'll need both the Windows SDK for Windows Server 2008 and .NET Framework 3.5 SDK AND Visual Studio 2008 installed; or the Microsoft Windows 7 SDK AND Visual Studio 2010.
HTML Help SDK 1.4 or higher [installed to Program Files or Program Files (x86)]
The missing registry key seems to be related to the VisualStudio SDK - you don't need this for basic WiX.
If you have all of the prerequisites, try passing the -debug switch to Nant for more detailed debugging output.
To solve this problem:
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
If you used Visual Studio 2010 SP1 you need Visual Studio 2010 SP1 SDK