Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 4.5.1 Preview Support in Visual Studio 2012

First let me add some context to error I get, I have installed .NET 4.5.1 Preview and first thing that I noticed in VS 2012 is that .NET 4.5.1 isn't listed in available frameworks. I'm not sure if this is correct behavior because this is just an upgrade to 4.5 so I guess VS 2012 should list it.

Further more when I installed a VS 2013 Preview, upgraded my project to .NET 4.5.1 and opened the solution in VS 2012 new .NET version reappeared so I'm not sure if this is a bug in VS 2012 or not ? Ok so now I have .NET 4.5.1 in VS 2012 and when I try to build a project I get the following error

Error   3   The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.  D:\Projects\MyProject\Master\Source\.nuget\nuget.targets    71  9   MyProject.Core.Modules

NuGet.targets reported line

<SetEnvironmentVariable EnvKey="VisualStudioVersion"
EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)'
!= '' AND '$(OS)' == 'Windows_NT' " />

It seems to me that for some reason VS 2012 can't resolve the paths or assemblies so I'm not sure if I should fix something in the NuGet.targets or is it a Visual Studio thing, any ideas ?

Thanks

like image 577
khorvat Avatar asked Jul 12 '13 06:07

khorvat


People also ask

Is .NET Framework 4.5 1 still supported?

Support for . NET Framework 4.5. 2, 4.6, and 4.6. 1 ended on April 26, 2022.

What is the .NET Framework for Visual Studio 2012?

The . NET Framework 4.5 includes enhancements for ASP.NET 4.5. Visual Studio 2012 also includes enhancements and new features for improved web development. This document provides an overview of many of the new features that are included in Visual Studio 2012.

Does .NET Framework 4.5 work on Windows 10?

NET 4.5. 1 cannot be installed on Windows 10, only 4.6 and later. So if your application is incompatible with . NET 4.6 and later you will need to update your application.

How do I enable .NET Framework 4.5 on Windows?

Select Start > Control Panel > Programs > Programs and Features. Select Turn Windows features on or off. If not already installed, select Microsoft . NET Framework and click OK.


3 Answers

i solved changing the ToolsVersion in .csproj file.

From

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

To

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
like image 60
Carmine Punella Avatar answered Oct 24 '22 02:10

Carmine Punella


Building .NET Framework 4.5.1 applications is supported in Visual Studio 2012. You need to either install Visual Studio 2013 Preview or Windows SDK for Windows 8.1 Preview to get the .NET Framework 4.5.1 Preview Targeting pack on the same machine as Visual Studio 2012 to build applications with .NET Framework 4.5.1 preview.

Thanks
Nithya [MSFT]

like image 11
user2608150 Avatar answered Oct 24 '22 03:10

user2608150


To fix this I had to upgrade the NuGet.targets and change the following two lines

From

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">

To

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">

Also it would be nice to get some answers related to .NET 4.5.1 Preview not showing up in VS 2012 up until I installed the VS 2013.

Nice chat with myself.

like image 7
khorvat Avatar answered Oct 24 '22 04:10

khorvat