dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

TargetFrameworkVersion 'v4.5.1' not supported by this toolset (ToolsVersion: 4.0).

Open ArsenShnurkov opened this issue 10 years ago • 2 comments

/usr/lib64/mono/4.5/Microsoft.Common.targets: Warning: TargetFrameworkVersion 'v4.5.1' not supported by this toolset (ToolsVersion: 4.0). (Npgsql.linux)

ArsenShnurkov avatar Jan 15 '16 04:01 ArsenShnurkov

http://stackoverflow.com/questions/31575206/targetframeworkversion-v4-5-1-not-supported-by-this-toolset-toolsversion-4-0 http://stackoverflow.com/questions/32296141/how-to-get-mono-to-use-the-right-toolsversion http://lists.ximian.com/pipermail/monodevelop-list/2014-December/016279.html https://msdn.microsoft.com/en-us/library/hh264221.aspx https://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.project.toolsversion.aspx https://msdn.microsoft.com/en-us/library/bb397428.aspx

The target framework is specified in the TargetFrameworkVersion property in the project file. https://github.com/npgsql/npgsql/blob/f7a75afa940bb8f0c434269f7208ff7ba9f8dff4/src/Npgsql/Npgsql.csproj#L19

The available values for TargetFrameworkVersion are v2.0, v3.0, v3.5, v4.0, v4.5, v4.5.1, v4.5.2, and v4.6:

  • The .NET Framework 2.0 (included in Visual Studio 2005)
  • The .NET Framework 3.0 (included in Windows Vista)
  • The .NET Framework 3.5 (included in Visual Studio 2008)
  • The .NET Framework 4.0 (included in Visual Studio 2010)
  • The .NET Framework 4.5 (included in Visual Studio 2012)
  • The .NET Framework 4.5.1 (included in Visual Studio 2013)
  • The .NET Framework 4.5.2
  • The .NET Framework 4.6 (included in Visual Studio 2015)

Specification of a target framework is required because it enables compiler features and assembly references that are exclusive to that version of the framework. The versions of the .NET Framework differ from one another in the list of assemblies that each makes available to reference.

https://github.com/npgsql/npgsql/blob/f7a75afa940bb8f0c434269f7208ff7ba9f8dff4/src/Npgsql/Npgsql.csproj#L2

If there is a ToolsVersion attribute on the Project element, then that is the effective Toolset version. Otherwise, the Toolset version is the same as the default Toolset version of the parent engine. When set, ToolsVersion overrides the current Toolset version of the project with the provided value. To get or set (override) the ToolsVersion attribute on the Project element, use the DefaultToolsVersion property.

from man xbuild (dev-lang/mono- (/usr/bin/xbuild))

    /toolsversion:version , /tv:version
              Specify the toolset version to use.
              Eg. /tv:4.0
                  This would cause 4.0 version of the Microsoft.Common.targets
              (among others) to be used. This overrides
                  the value specified in a project file.
              Valid values: 2.0, 3.0, 3.5 and 4.0

https://github.com/mono/mono/tree/master/mcs/tools/xbuild https://github.com/mono/mono/tree/master/mcs/class/Microsoft.Build.Engine https://github.com/mono/mono/blob/6c066a6580729eadc8c88f4e3d26f9c576ec4b8e/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs#L108-L125

        //FIXME: should be loaded from config file
        void LoadDefaultToolsets ()
        {
            Toolsets.Add (new Toolset ("2.0",
                        ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20)));
            Toolsets.Add (new Toolset ("3.0",
                        ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version30)));
            Toolsets.Add (new Toolset ("3.5",
                        ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version35)));
            Toolsets.Add (new Toolset ("4.0",
                        ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
#if XBUILD_12
            Toolsets.Add (new Toolset ("12.0", ToolLocationHelper.GetPathToBuildTools ("12.0")));
#endif
#if XBUILD_14
            Toolsets.Add (new Toolset ("14.0", ToolLocationHelper.GetPathToBuildTools ("14.0")));
#endif
        }

Remaining questions: Q1:are XBUILD_12 and XBUILD_14 enabled by default? https://github.com/mono/mono/blob/03207c185fa7269204997c0e5ea4ffbe78ef2116/runtime/Makefile.am#L31 Q2: where TargetFrameworkVersion list of values is defined in source code? Q3: How mapping between toolsets an frameworks are defined in code? Q4: How ranges are defined? Q5: how to test does xbuild support specific toolset? Q6: how to test xbuild features from ./configure?

ArsenShnurkov avatar Jul 31 '16 03:07 ArsenShnurkov

it will be great to have such research and answers on all those questions, some of questions will be fine asking on StackOverflow (because it's full of actually .NET devs)

With xbuild 14 you mean ToolsVersion 14? I guess it should be default one now however it's sometimes hard to say for me which one is used even on windows. not really sure if that is related https://msdn.microsoft.com/ru-ru/library/bb383796.aspx For other questions - no idea...

Cynede avatar Jul 31 '16 06:07 Cynede