With the current source code, projects which won't load in VS 2015. I also tried some older branches and while the projects load, they seem to be dependent on packages that are no longer available. I don't mind if its older version.
If you look at the tag on the github repository for version 1.0 that should build under Visual Studio 2015
Related
I am considering which is the difference between tis two packages. If i will search in references of visual studio i will find System.Net.Http.dll version 4.0.
But if i will look into nuget packages i will find a version 4.3.4.
Both of them are work very nice. But which of two is better to use visual studio or from nuget?
Thank you
The version you are seeing in Visual Studio is predicated on the version you are running of .Net. Each version of .Net Core's SDK could potentially have a different version of System.Net.Http.dll. What you are seeing in Nuget is the latest version, which does not appear to match the version for your currently used .Net SDK.
I've inherited a set of build scripts which currently look inside the .sln file, work out what version of Visual Studio they were created with, and then call the version of MSBuild associated with that version of VS.
Is that necessary? Or will the latest version of MSBuild compile older solutions/projects?
Can newer versions of MSBuild compile older C# solutions?
The simple answer is yes.
When building the project from Visual Studio, Visual Studio will call devenv.exe to build the project, then devenv calls msbuild to perform the build.
As per official document Port, Migrate, and Upgrade Visual Studio Projects:
Each new version of Visual Studio generally supports most previous types of projects, files, and other assets. You can work with them as
you always have, and provided that you don't depend on newer features,
Visual Studio preserves backwards compatibility with previous versions
like Visual Studio 2015, Visual Studio 2013, and Visual Studio 2012.
Support for some types change over time, however. A newer version of Visual Studio may no longer support certain types, or require that
they be migrated and updated such that they're no longer
backwards-compatible.
So the latest version of MSBuild supports most previous types of older solutions/projects except those no longer support by the newer version of MSBuild.
To use the new C# 7.1 language features with Visual Studio 2017, you add the setting <LangVersion>latest</LangVersion> to your project file(s).
However, building such projects from MSBuild (version 15.3.409.57025, located at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin) results in an error:
CSC : error CS1617: Invalid option 'latest' for /langversion;
must be ISO-1, ISO-2, Default or an integer in range 1 to 6.
Is this feature just not yet supported by MSBuild, or is it possible to get this working?
This covers 200+ projects that were originally created variously in Visual Studio 2013 and 2015. They were all re-targeted to .NET 4.7 using the Target Framework Migrator tool (which saved lots of clicking and appears - based on inspecting .csproj file changes - to do the job correctly).
The projects all build successfully from Visual Studio 2017.
Nuget packages
Microsoft.Net.Compilers nuget package does not work and needn't to be installed.
Set the following project/build settings
Set at least C# 7.1 or higher in the Debug and Release build properties. (via: Project menu > [ProjectName] Properties > Build tab > [Advanced] button > Language Version).
Setting it to latest does not work.
Also make sure that you are running the latest MSBuild version.
Add a reference to the Microsoft.Net.Compilers package (version 2.3.x, to get C# 7.1).
A short description of the package:
Microsoft.Net.Compilers
This package not only includes the C# and
Visual Basic compilers, it also modifies MSBuild targets so that the
included compiler versions are used rather than any system-installed
versions. Once installed, this package requires Microsoft Build Tools
2015.
Make sure you have changed for "All Configuration" and not just "Debug"
else you will be baffling why it is failing at production.
In case you land here because you get the error as the OP mentioned, running msbuild via command line (e.g. from a build agent such as jenkins), the solution may be as easy as to upgrade Microsoft Build Tools 2015.
You can do that via choco install microsoft-build-tools or manually via the official Microsoft Build Tools 2015 or by updating your Visual Studio 2017 installation.
I've got a solution with a C# console app using C# 7.1 here.
Using the VS 2017 command line (and thus MSBuild 15.3.409.57025) it worked fine. (The .csproj does contain <LangVersion>latest</LangVersion>.)
Is this feature just not yet supported by MSBuild, or is it possible to get this working?
Yes it is.
Which instance of csc.exe is being run and what's its version? Because it looks like, despite quoting the version, you have the wrong version of csc.exe (the error message says 1-6 so not even C# 7 would work).
We discovered that our MVC projects were triggering this issue.
To fix, we updated the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package used by these projects from version 1.0.0 to 1.0.7.
As I learn that I can compile C#6.0 code to run on lower .NET framework,
Does C# 6.0 work for .NET 4.0?
Post-Answered Note: I realized that the post above only shows that C#6.0 can compile
on .NET 4.0. For lower .NET, here is the answer from Mr. Jason
Malinowski, who works on the Roslyn project:
"I can't think of a reason why it wouldn't work, but I'm not sure how
much that has been tested"
I learn how to code in C#6.0 in Visual Studio 2013 and I read some posts regarding the topic:
Using Roslyn compiler with Visual Studio 2013
How to enable C# 6.0 feature in Visual Studio 2013?
How can I add C# 6.0 to Visual Studio 2013?
And also watching a video:
https://www.youtube.com/watch?v=tTdhlJFzCRA
What I basically understand from them are:
You can have C#6.0 feature enabled in VS2013 by using Roslyn Compiler
You could use Microsoft.Net.Compilers NuGet package to use Roslyn compiler, but with the cost that the VS2013 itself won't "understand" some codes since the VS2013's internal "live" compiler is not the same as Roslyn.
There was once upon a time where such is supported. https://github.com/dotnet/roslyn but the latest version for this is April's End.
(Side question: Anything wrong with my understanding?)
Now my questions are:
As of now, is the a way to workaround with Microsoft.Net.Compilers NuGet package and VS2013 internal "live" compiler such that it can "understand" C#6.0?
"There was once upon a time where such is supported" how can I get this project. As I download the project from github and tried to open it with VS2013, I got the following error:
Can we still use the April's End version well in VS2013 that it will understand what it tries to compile?
Any other workaround for this? I would be happy as long as I can code with C#6, using VS2013, and compile it to lower .NET framework.
Thanks!
Note: Unfortunately, using Visual Studio 2015 is not an option for me...
To summarize the compatibilities and incompatibilities:
C# 6.0 (the language) can be used to compile applications that run .NET 4.0; i.e. it does not require .NET 4.5 or higher.
There is no supported way to make Visual Studio 2013 understand C# 6.0 code in the IDE. We did release, as you observe, previews of pre-6.0 things that ran on Visual Studio 2013. Those were just intended to be previews while we finished all the work of making Visual Studio 2015.
You can install the NuGet package to make the build use C# 6.0 under Visual Studio 2013, but the IDE will still not understand C# 6.0 features and Intellisense and friends will be broken.
To build the Roslyn source code as-is (and of this writing), you need Visual Studio 2015 with Update 1, or equivalent tools for Mac/Linux.
Our tests use Microsoft.Build.Evaluation.Project.Build to build projects.
Works fine for VS 2010 & 2012. Trouble is in VS 2013, it picks up msbuild from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
ver 4.0.30319.18408
instead of from VS 2013
C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe
ver 12.0.21005.1
Is there any method to ask it to pick up the VS 2013 msbuild?
May be adding to the .proj file or setting an environment value before calling the build method?
MSBuild and its Toolset now Version with Visual Studio
We plan to evolve our build tools with each version of Visual Studio from now on. Each release of the Micrsoft® Build Tools will have a new version of MSBuild, the VB/C# Compilers, and Toolset. They will all version together. Visual Studio will use its corresponding version of MSBuild exclusively. For instance, Visual Studio 2013 will exclusively use MSBuild 2013 and ToolsVersion=”12.0”. To align with Visual Studio’s versioning we have updated MSBuild’s assembly version from 4.0 to 12.0 as well.
And a link to the visual studio team page, with a few additional defaults to check
http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
however 4.0 and version 12 are the same; re-versioned to support the visual studio version number format
from:
http://en.wikipedia.org/wiki/.NET_Framework_version_history#.NET_Framework_4.5
//Quote//
.NET Framework 4.5 was released on 15 August 2012.,[27] a set of new or improved features were added into this version.[28] The .NET Framework 4.5 is only supported on Windows Vista or later.[29][30] The .NET Framework 4.5 uses Common Language Runtime 4.0, with some additional runtime features.[31]
//End Quote
Since 4.5 is an "upgrade" to the 4.0 library......."C:\Windows\Microsoft.NET\Framework\v4.0.30319\" is where I would expect it to find its version of MsBuild.exe.
Are the MSBuild.Exe (that you list) different?
You could experiment with overriding the
<Message Text=" MSBuildBinPath = $(MSBuildBinPath)" />
property.