.Net class library compilation error on build machine - visual-studio

I have a SDK styled .Net class library which compiles properly on my local machine, however fails on build server.
The contents of .csproj are
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;net40;netstandard1.0</TargetFrameworks>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<Version>1.5.6</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
</Project>
The error displayed is:
NETSDK1045: The current .NET SDK does not support targeting .NET Standard 4.0. Either target .NET Standard 2.1 or lower, or use a version of the .NET SDK that supports .NET Standard 4.0
I have .NET Core 3.1.113 installed on build server and .NET 5 installed on local machine.
Note: If I remove netstandard1.0 from TargetFrameworks then build succeeds on both the machines. However I want my library to target .net standard 1.0 as well.
I cannot understand why v4.0 is treated as .NET Standard 4.0 on build server. Can anyone let me know what the problem might be?

Remove the following line from your .csproj file:
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
This overrides the version value that the SDK infers from TargetFramework which will interfere with your definition of net3.5 and so on - you were actually building .NET Framework 4.0 twice and then override netstandard1.0 to .NET Standard (inferred TargetFrameworkIdentifier) to 4.0. Newer versions of the SDK may have different inference logic which may be a difference between 3.1 and 5.0 SDKs but this is an error in the csproj nonetheless.
If your build logic relies on TargetFrameworkVersion being defined in the project I suggest you try to change your build logic - this is VERY DANGEROUS to have in a modern csproj file where you rely on TargetFramework and TargetFrameworks (plural). You can also try to move it into a separate <PropertyGroup> with an always-fals-condition (e.g. <PropertyGroup Condition="'$(ThisIsToWorkAroundBuildScripts)' == 'True'">)

I cannot understand why v4.0 is treated as .NET Standard 4.0 on build
server. Can anyone let me know what the problem might be?
That is quite strange and I have not seen that issue before. And there is no info about .NET Standard 4.0 and I did not know why VS treats v4.0(net framework 4.0) as net standard 4.0. Maybe your there is some problems about your server environment.
Please follow these:
1) First, please use dotnet --list-sdks under CMD to check if you installed net core 2.1 sdk or any other versions. And actually, net core 2.1 sdk could support the previous sdks including net standard 1.0. Maybe you would better install net core 2.1 sdk. Also, you could install the latest Net Core 3.1 Sdk.
2) check system environment variable, and find whether there is a variable called MSBuildSDKsPath, if so, please delete it. Then, restart.
3) delete bin and obj folder under the build server. Also, I suggest you would better use Build Tool for VS to build your projects on the server rather than dotnet build. dotnet cli does not contain the tool for net framework. What's more, your project is multi-targetframeworks, it could build net core and net standard, and also you have to download net framework sdk.
That is too complex, you could install the Build Tool for VS2019(more likely a lightweight cmd which integrates dotnet, net framework, all vs environment). Also, install the Net desktop build tool and net core build tool workload, also install the related sdks.
When you finish it, delete bin and obj folder, type this under Build Tool for VS command:
msbuild xxx\xxx.csproj -t:clean,restore,build

Related

VS 2019 Project Target Framework Not Installed - .Net Framework 4.0

Just installed VS 2019 Pro on a new system. When I open a solution with .net 4.0 project, I get this error: Project Target Framework Not Installed.
When I choose download it, it goes here but does not have option for .net framework 4.0.
In project settings there is no option for .Net Framework 4.0 in targeting framework:
https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk
I have tried installing 4.6.2, 4.5.2, etc.
How can I get this project to open? It opens on my other machine. It has these options for Target framework in project settings:
Please don't say change the framework version, we need this older version for very old computers running XP and Win 7 that cannot be upgraded.
thank you
You have to go directly to their download site. As shown in another correct answer that was downvoted, it's still available even though it's past end-of-life.
https://stackoverflow.com/a/72870727/9008140
You can package the install files with your app just in case, although most likely your installer will see that it's missing and download it anyway.
You can try downloading .Net 4.0 here: https://dotnet.microsoft.com/en-us/download/dotnet-framework/net40
Mandatory warning: Installing an old, unmaintained .Net framework comes with security risks. It's up to you to determine how much those Windows XP PCs are vulnerable and manage said risks.

ABP 3.0 differences between Full and Cross Net Framework template

Related to "Free Startup Templates" for the last ABP 3.0 version, what are the differences between the Full .NET Framework and .Net Core (Cross Platform) versions?
I presume you are talking about the ASP.NET Core 2.0 target framework, either Full .NET Framework and .NET Core (Cross Platform)?
I think the code is more-or-less the same (as mentioned by #Alper Ebicoglu the .NET Core project is missing the SignalR implementation) but the output from the build will be for .NET Framework 4.6.1 as supposed to for .NET Core.
Basically they're building a .NET Framework project using .NET Core tools which you can do.
For example:
Create a temp folder and open Command Prompt or PowerShell in that directory. Then run dotnet new console, then dotnet restore and finally dotnet build. You should get a message like temp -> C:\Source\temp\bin\Debug\netcoreapp2.0\temp.dll
Edit the .csproj file and change the TargetFramework property to net461. Run dotnet build and you'll see a different message temp -> C:\Source\temp\bin\Debug\net461\temp.exe.
In the first instance you created a .dll to run cross platform using dotnet run and in the second instance you created a .exe which will only run on the Windows platform.
I hope I'm answering what you're asking and this helps.
if we talk about only aspnetboilerplate framework; the only main difference is, currently in .NET Core platform SignalR implementation is missing.

How MSBuild multitargeting works

I will try to explain this as clear as I can
I want to fully understand how MSBuild multitargeting works.
I have read several articles from Microsoft and I think I understand the basic but I want to be sure I am not missing anything.
According to Microsoft:
By using Visual Studio, you can compile an application to run on any one of several versions of the .NET Framework. For example, you can compile an application to run on the .NET Framework version 2.0, and compile the same application to run on the .NET Framework version 4. The ability to compile to more than one framework is named multitargeting.
Visual Studio runs under the most current version of the .NET Framework that is installed on the development computer.
http://msdn.microsoft.com/en-us/library/ee395432.aspx
So do this mean that Visual Studio always calls MSBuild from the latest framework installed? assuming Visual Studio 2010 is installed, it will always call: %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe when building any project targettting any .Net Framework version right???
If yes, then the ability to target old .Net Framewrok versions is based on the ToolsVersion and/or TargetFrameworkVersion properties right???
If yes again, it would mean that just installing the latest framework (and also the older frameworks but not installing visual studio) in my Continuous Integration box, I could point to build always any solution to: %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe and just specify the ToolsVersion argument (if required, since each project can have its own target version specified in the TargetFrameworkVersion which it would cause to target an older .Net Framework version).
Following this I think my CI box would be building like Visual Studio does. Am I right? What am I missing? Is there a way to be completely sure?
I did a quick test, and I think it works :p the projects are being built according to the .Net Framework specified but like I said I want to be sure I am not missing anything.
Any thoughts?
BTW:
The simple reason to want to do that is because I have several custom MSBuild scripts that are reusable accross projects, but some of the functionality in these scripts require MSBuild 4.0 and also I have several MSBuild tasks built on top of the framework 4.0 so if I have for example a solution targetting the Framework 2.0 and I try to build it using: %WINDIR%\Microsoft.NET\Framework\v2.0.50727\MsBuild.exe I get MSBuild errors trying to load my custom targets
Yes, you've got it mostly correct. Calling MSBuild from the 4.0 directory will do the correct thing against previous versions. They only thing I wanted to add was that 3.5 must be on the box to actually build projects targeting 2.0, 3.0 and 3.5.
This page here: http://msdn.microsoft.com/en-us/library/bb822049.aspx calls out the what versions Windows comes with what version of the framework pre-installed.

Windows CE project with libraries problem

I am developing a Windows CE application which uses some libraries provided by other parts of our company.
When I deploy my application on "My Computer" (.NET compact application running on standard PC), everything works, but when I deploy to the device, the application hangs when trying to use methods from the library. The system also hangs. My Visual Studio 2008 sometime hangs, but sometime throws an exception "TypeLoadException: Could not load type from assembly Culture=neutral, PublicKeyToken=nu".
I couldn't include .NET Compact framework 3.5 because the image wouldn't compile, so I am using version 2.0. I use Visual Studio 2008 with deploy .NET framework option.
Most probably the problem is with version of the library you are using. Please cross check it.
Hope this link will help you.
I'm a bit confused.
First of all, what are the libraries "provided by other parts of [y]our company" build against? Are they Compact Framework assemblies (they must be)? What version of the Framework were they build against? Reflector can tell you this if you don't know.
Second, why can't you compile it with 3.5? What sort of errors are you seeing? The code should be 100% forward compatible, so if it won't build, there's a red flag going up.
Lastly, what version of the CF is installed on the target hardware? FOr example, are you trying to push a CF 2.0 app to a device with CF 3.5 already installed? If so, do you have an app.config file that provides the framework compatibility options so it knows it can run your assembly?
The problem was that libraries were compiled with for 3.5 target framework, and the application which uses them form 2.0 framework. In that case, 3.5 framework wasn't depoloyed and application would stop working as soon as call to the library methods was made.

.Net Framework 3.5 is needed for installing my VB 2008 Project?

Using VS 2008
I created a setup file for my Project, I run the setup file in my system, and My Project is working fine.
If I install my project to another system, is asking .Net Framework 3.5 at the setup time.
.Net Framework 3.5 is needed for installing my Project?
Before i installing my project, i install the .net framework 3.5, It taking to much time to setup?
How to solve this? or any other way to create a Project setup ?
Can any one help to solve my setup problem.
What you need to do is right click on the setup project in the SolutionExplorer and select the Properties menu option. You can then click on the Prerequisites button. This allows you to control what your setup program needs/wants in order to install your code.
If you don't need .NET 3.5 then just unselect it. This is just one more annoying thing that VS2008 does, you select .NET 2.0 as your target framework but it leaves .NET 3.5 as a pre-req.
If it is important for you that your program does ot require .NET 3.5, you can set up your project to target .NET 2.0. The the setup project will also see this, and (hopefully) remove the dependency when you update it.
If your project is VB.NET, you can set the Target Framework version here:
Project Properties -> Compile -> Advanced Compile Options...
If Your project is C#, it is here:
Project Properties -> Application
If you do this, of course you will not have available any .NET 3 specific functionality.
Do you rely on .net 35 features in your code. If not you can recompile with the project settings targetting .net 3.0 or 2.0.
The .NET 3.5 framework has two different installers to choose from: the bootstrapper and the full package.
The bootstrapper installer is small in size (2.7 MB). It's small because it downloads the required files from the internet when executed on the target machine. Depending upon the target's network bandwidth, it may take a long time to run.
The full package installer is large (237 MB), and does not require an internet connection to run.
If you are currently using the bootstrapper installer, you should try downloading the full package installer and running that on the target machines.
(That is, if you actually need .NET 3.5)
You can select either installer from here.

Resources