One F# 4.1 compiler includes targetPlatform value of netstandard, the other does not - f#

The F# 4.1 compiler on my build machine has slightly different --targetProfile options than the F# 4.1 compiler on my dev machine.
On my dev machine, when I type fsc.exe -? the output includes the following:
Microsoft (R) F# Compiler version 4.1
:
--targetprofile:<string>
Specify target framework profile of this assembly.
Valid values are mscorlib, netcore or netstandard.
:
On my build server, the same command outputs the following:
Microsoft (R) F# Compiler version 4.1
:
--targetprofile:<string>
Specify target framework profile of this assembly.
Valid values are mscorlib or netcore.
:
Notice that the dev machine includes netstandard as a valid value, but the build server does not.
Consequently, when I try to build my project on the build server, I get a compile time error of "error FS1052: Invalid value 'netstandard' for '--targetprofile'"
What is going on? Is there a way to display the real version number of an F# 4.1 compiler? fsc.exe --version does not work.

I don't think this is to do with the F# compiler version but rather the .NET SDK(s) installed.
Check the target framework TFMs.
I have mscorlib, netcore or netstandard and I will take a stab at where they come from:
mscorlib from full framework...comes with Windows
netcore installed with VS 2017 when selecting ".NET desktop development"
netstandard installed with NET Core SDK
If this is the case I would imagine installing .NET Core SDK on the build server would sort it out since you seem to be targeting netstandard.

Related

What's the difference between SDK and Runtime in .NET Core?

I've read many articles, including this one, yet I can't still figure out what's the difference, and they have not explained it either in simple terms or at all.
Can someone please clarify what's the difference between .NET SDK and .NET Runtime?
Update: Using comparisons would be very appreciated. Analogy alongside simple English is highly educational.
According to the .Net Core Guide, .NET Core is composed of the following items
A .NET runtime, which provides a type system, assembly loading, a garbage collector, native interop and other basic services.
A set of framework libraries, which provide primitive data types, app composition types and fundamental utilities.
A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.
The 'dotnet' app host, which is used to launch .NET Core apps. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way.
The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.
The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.
Only the latter is required to run the application, but the former is needed to develop the application.
Runtime: to run apps
SDK (Runtime + Tooling): to build and run apps
I'm not inventing anything here. Just copy-pasting the definitions from https://dotnet.microsoft.com/download
The software development kit (SDK) includes everything you need to build and run .NET Core applications, using command-line tools and any editor (like Visual Studio).
The runtime includes everything you need to run .NET Core applications. The runtime is also included in the SDK.
Sharing from Rick Strahl's post: Which .NET Core Runtime Download do you need?
Only the .NET Core Runtime is required to run an application and provides information about the install.
To develop, build and publish an application will require an SDK.
dotnet.exe installs with a runtime install, but it only provides core features to provide info to run an application and provide info about the install: dotnet mydll.dll and dotnet --info. To build, publish or do anything else you need to install the SDK.
Running the following command will provide information about the install:
dotnet --info
If the command fails it means you do not have the .NET Core runtime installed or available in the system's PATH.
Below is a sample output of the command.
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.101
Commit: 236713b0b7
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.101/
Host (useful for support):
Version: 2.2.0
Commit: 1249f08fed
.NET Core SDKs installed:
2.1.4 [/usr/local/share/dotnet/sdk]
2.1.302 [/usr/local/share/dotnet/sdk]
2.2.101 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The output tells you:
The installed SDK version
The active runtime version that's running this dotnet command
A list of all installed runtimes and SDKs
Installing an SDK also installs the runtime.
macOS homebrew specific
Installing the homebrew-cask dotnet will conflict with the dotnet-sdk, so to get both the runtime, and the sdk install dotnet-sdk
brew cask install dotnet-sdk
In short, the runtime will allow your OS to run compiled C-Sharp, C# programs, and the sdk will allow you to compile programs written in C-Sharp, C#.
It's important to understand that you can have multiple runtimes and multiple SDKs installed and each project can use a different one. The runtime is determined by your project's runtime specifier in the .csproj file:
<TargetFramework>netcoreapp2.1</TargetFramework>
The SDK is either the last globally installed SDK which is the default, or you can explicitly override the SDK in a global.json placed in the solution root folder. The following explicitly forces my project to use the last RC SDK, instead of the RTM version:
{
"sdk": {
"version": "2.1.300-rc.31211"
}
}
Generally, there should be no need to use a specific lower SDK version as the SDK is backwards compatible and can compile various versions of .NET Core applicatino back to v1.0. IOW, it's OK to use the latest SDK in almost all cases.
.NET Core Runtimes
The .NET Core Runtimes are the smallest self-contained and specific component and contain the absolute minimum to run just .NET Core on a specific platform.
Note it a runtime install does not include the ASP.NET Core meta package runtime dependencies, so if your application references Microsoft.AspNetCore.App or Microsoft.AspNetCore.All you have to seperately download the ASP.NET Core package. However, if you explicitly reference all ASP.NET Core Nuget packages rather than using the meta packages, those packages are deployed as part of your application and it can run with just the runtime.
Essentially you are trading installation package size vs. a runtime pre-install requirement.
References:
Which .NET Core Runtime Download do you need?
The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.
The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.
As summary:
If you install SDK, you will have everything you need for development and running the app.
adding to stormwild's answer in case you have only the .Net Core Runtime installed you will receive the following output from dotnet --info
>PS C:\Users\Administrator> dotnet --info
>
>Host (useful for support):
> Version: 2.2.3
> Commit: 6b8ad509b6
>
>.NET Core SDKs installed:
> No SDKs were found.
>
>.NET Core runtimes installed:
> Microsoft.NETCore.App 2.2.3 [C:\Program
>Files\dotnet\shared\Microsoft.NETCore.App]
Runtime is enough if we want to run just application on hardware, otherwise to develop and run we need SDK (which includes runtime and tooling).
SDK ==> to build and run .NET apps
Runtime ==> to run .NET apps
Easy! :)
The SDK usually includes documentation and other help files. The runtime contains only the binary files for the installation.
When you install SDK you also get runtime in that. Check this below, this is what gets installed when we install SDK.
The following were installed at C:\Program Files\dotnet
• .NET Core SDK 2.2.100
• .NET Core Runtime 2.2.0
• ASP.NET Core Runtime 2.2.0
SDK is required to compile source code and generate bytecode/Intermediate Language Instruction for a specific target OS/runtime. SDK is not tightly coupled to target OS. For ex - SDK installed on Windows can generate bytecode for Linux.
dotnet build --runtime ubuntu.18.04-x64
Runtime is required to run bytecode on a specific OS. Runtime is specific to OS. Runtime for Ubuntu is different than Windows.
Runtime is what makes .Net Core special. Runtime allows .Net apps to be "Write Once, Run Anywhere" similar to Java.

F# (mono) for VS Code on MacOS : bugs

I'm trying to use F# with VS Code (v1.17.2) on MacOS (Sierra 10.12.6)
I think i've installed latest versions of Mono and .NET SDK
I'm trying just to build the simple project described here as a test
https://github.com/s952163/FSharpVSCode
after my default installation, I could do a MSBuild and run the program in the terminal without any problem. However at that stage,
(1) Intellisense is not working properly, not recognizing Deedle
(2) in the F# explorer it would say
'TestProject1.fsproj (load failed)
when doing a right-click i got this error
Error: MSBuild failed with exitCode 1 Working Directory:
'/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1'
Exe Path: 'dotnet' Args: 'msbuild
/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj
/p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true
/p:CopyBuildOutputToOutputDirectory=false
/p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs
/p:_Inspect_FscArgs_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmp52c377ed.tmp.FscArgs.txt
/p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences
/p:_Inspect_GetResolvedProjectReferences_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpfe4a2c2.tmp.GetResolvedProjectReferences.txt
/t:_Inspect_GetProperties
/p:_Inspect_GetProperties_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpfe4a2c2.tmp.GetProperties.txt
/nologo /verbosity:quiet' Log: writing helper target file in
'/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/obj/TestProject1.fsproj.proj-info.targets'
/usr/local/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1122,5):
error MSB3644: The reference assemblies for framework
".NETFramework,Version=v4.6.1" were not found. To resolve this,
install the SDK or Targeting Pack for this framework version or
retarget your application to a version of the framework for which you
have the SDK or Targeting Pack installed. Note that assemblies will be
resolved from the Global Assembly Cache (GAC) and will be used in
place of reference assemblies. Therefore your assembly may not be
correctly targeted for the framework you intend.
[/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj]
to try to solve this, i typed in the following
export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/
but worse, after that, the project doesn't build anymore in VS Code as I get this output when trying (Cmd-Shift-P) MSBuild: Build Project
/usr/local/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj]
screenshot here https://imgur.com/KtMM2Bu
VS Code environment is passed to msbuild when it invokes it, so setting environment variables on startup of VS Code does the trick:
FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/ code .
Go to project location in the terminal and then run FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/ code . as said before.
Then you should be able to build again.

Net standard Library missing reference in ASP.NET Boilerplate

every time i clone Abp.ModuleZero to my machine when i run nuget command update-database the error show me and when i build the solution in viusal studio the project doesn't build and show many errors in error list console window
most of them is like :
The type 'Object' is defined in an assembly that is not referenced.
You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
i try to install Netstandard.library package from package manager console window but doesn't any sense.
my visual studio IDE version is 2015 Update 3.
ABP v3.0.0 is based on .NET Standard 2.0.
This concerns you regardless if you are on MVC 5.x, .NET Framework 4.x or .NET Core 2.x.
You should use VS2017 15.3.3+.
For VS2015, you may try installing NuGet client 3.6 or higher but that may no longer work.
i think downgrade to earlier version of this framework is good solution for me, where can i download early version of ABP framework like 2.3.4?
I don't see why you would download the framework, but it's on GitHub.
If you meant download a template that uses an earlier version of ABP:
You can only choose the project version for premium startup templates.
You can build your own from module-zero-core-template/releases/tag/v2.5.1.
You need to rename the files and folders yourself.

Deploying F# exe

I have an F# program I built in VS2013. I am intending to deploy this on a windows 2008 R2 server with .NET framework 4.5 installed. Now, when I build the program in visual studio, it creates an exe in the debug/bin directory (MyProgram.exe). Do I need to include a copy of fharp.core.dll with the exe? Or, will the build process automatically compile the necessary dependancy DLLs (fsharp.core, fsharp.data, fsharp.data.TypeProviders)? Most of the research I can search online for seems to look at VS2010 and I am not using fsc,exe currently.
Thanks for any insight provided.
You can use the compiler option --standalone to statically links the FSharp.Core.dll (F# runtime) and any reference assemblies that depend on it (i.e. any other F# assemblies).
You may or may not need to copy FSharp.Core.dll together with the .exe.
If F# is already installed on the server, you may not need it, but it has to be the correct version of F#.
Otherwise, the F# license allows you to deploy FSharp.Core.dll together with your own binaries.
There's also the 'official' FSharp.Core NuGet package, if that's more to your liking.

VS 2010, TFS 2013 SGEN: An attempt was made to load an assembly with an incorrect format

I am working on a conversion of tfs 2013 build definition, we were initially using tfs 2008.I have a new server with TFS2013 installed and working on Build definition for 2013 xaml (workflow) customization is completed. However i am facing an error when my TFS build in release mode for Any Cpu configuration, but its fine when i use debug mode. I have tried looking many articles and unable to find any solution kindly help me here. This is fine in my local machine but happens only in the server.
Project and details
1) project is .net framework 4.0
2)Default configuration is "Any Cpu"
3)TFS 2013 server is 64 bit, windows server 2008 r2
Build Definition
Configuration : Any CPU|Release
MsBuildPlatform : x86
Error:
SGEN: An attempt was made to load an assembly with an incorrect format: C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll.
Warning:
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (990): The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
I have installed windos 8 SDK (Tools only)
and Windows framework 4 x64 as x86 version is failing
The folder C:\Program Files\Microsoft SDKs\Windows has v7.0 folder
C:\Program Files (x86)\Microsoft SDKs\Windows has v8.1A folder
where as my local machine has many versions inside the windows folder in above path
List of related articles which i have checked,but couldn't find a solution
http://seravy.wordpress.com/2012/10/25/installing-net-4-5-and-not-windows-sdk-8/
http://blogs.msdn.com/b/windowssdk/archive/2009/09/16/windows-7-sdk-setup-common-installation-issues-and-fixes.aspx
Running MSBuild fails to read SDKToolsPath
http://dukelupus.wordpress.com/2008/02/05/task-failed-because-sgenexe-was-not-found-solution/
How do I fix the Visual Studio compile error, "mismatch between processor architecture"?
TFS 2010 creating .Net 4.0 XmlSerializers DLL for .Net 3.5 Application
So what should i do to fix this error ?
You need to install the targeting packs (aka SDK, aka Developer pack) for the .NET Framework version you are targeting. You can download them all from http://blogs.msdn.com/b/dotnet/p/dotnet_sdks.aspx
Specifically for your question and targeting .NET Framework 4.0, you want Windows SDK for Windows 7 and .NET Framework 4 Sounds like you grabbed the Windows 8 SDK, which is not what you want for targeting .NET Framework 4.0.
This is not a very good answer (but in case someone comes across it like me), and does not provide insight into why it is occurring. But turning off "Generate the serialization assembly" on the offending project does allow for the build to work in my case.
Start up times will be slower, as serialization will occur at runtime instead now.
You simply need to see what framework you are using and then what debug mode you are using.
In my case i was using framework 4.0 and Build mode target framework "any cpu" but after searching around i found that i need to upgrade my .Net framework from 4.0 to 4.5 and i have to build my solution from "any cpu" to x86 framework because i had Windows 7 SPI with x86 architecture.
Here are some images what i have done to solve this error.
I encountered this error (albeit for a newer .NET framework version, v4.5.1, not v4.0 as in the original question) when trying to build my application on a build server.
The combination of the following two conditions was responsible for the error:
In Visual Studio, on the Project Properties page, on the Application tab, the "Target framework" was set to ".NET Framework 4.5.1";
On the build server, in folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework, a folder named v4.5.1 was not present. (Other folders with version numbers, including v3.5, v4.0, and v4.5, were present.)
This missing folder was the cause of the "The reference assemblies for framework ... were not found" warning, which in turn lead to the "assembly with an incorrect format" error.
The fix was to install Windows Software Development Kit (SDK) for Windows 8.1 on the build server. In the install wizard, in the "Select the features you want to install" step, I unchecked all boxes except for the one for ".NET framework 4.5.1 Software Development Kit".
Running that install caused the missing v4.5.1 folder in the Reference Assemblies\Microsoft\Framework.NETFramework folder to be created, and the build to run successfully.
I am reluctant to answer because you say you have already done this, but every time I have struggled with the error message you quote, it has been the MsBuildPlatform setting. It absolutely has to be set to "X86". Are you sure the setting is being set..?

Resources