MSBuild update, where dos this come from? - c#

Here is the context :
2 persons are working on a WPF application (me and a colleague)
we both use the VS 2017 (i have the version 15.6.6 he has the version 15.6.4)
we are both using the most recent and fully updated .NET Framework
we are using MSI installation system to deploy our WPF application + Win services
we are using WIX to package all this
But something strange happened: when I generate the installer, the netstandard.dll version deployed is the 4.6.25908.2, and when he generates the installer, the netstandard.dll is the 4.6.26011.1
After some research, we discover that this dll is coming from MSBUILD, and by checking in the "Developer Command Prompt for VS 2017", using the "msbuild" command :
- my version is 15.5.180.xxxx
- his version is 15.6.6.xxxx
My question is pretty simple, what is responsible for updating msbuild package?
Obviously, not VS or .Net Framework
I have found some nugget package to add to my projects but I don't want this, I want this dll to be updated properly in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib" directory
How can I manage to achieve this?

Ok I found what was going on and there was no way to find out with what I posted.
This is the story :
I installed VS 2017 Pro with a license
I tried VS 2017 Enterprise for sometimes with a trial license
VS 2017 setup made 2 distinct installations
After the trial license expired, I was still using then Enterprise installation downgraded to a Pro version
The Enterprise version was up to date but not the original Pro version
Conlusion: by updating the VS 2017 Pro version specifically, it solved my problem
#Hans Passant: the MSBUILD was indeed updated with VS 2017, but for some reason, I don't really understand, I have to update both Pro and Enterprise version to 15.6.6.xxxx in order to update MSBUILD properly

Related

Visual Studio 2019 shows an empty solution after creating a .NET Core project

When I create a new .NET Core project in Visual Studio 2019, it shows only the solution file. Other files are not showing and also I am not able to debug or the project.
I've also run into this problem and after two days of searching forums and reading .NET documentations, I finally managed to find the solution.
The problem is that Visual Studio cannot find the proper SDK version. There might be a few reasons for this, but first of all, check if you have any SDK installed:
Open the Command Prompt:
Start Menu > Visual Studio 2019 > Developer Command Prompt for Visual Studio 2019
Run the command: dotnet --info
Case 1:
The .NET SDKs installed: section says that you have no SDKs installed.
-OR-
A .NET SDK is installed but not for the right architecture (this was my case), meaning that you had installed x86 version instead of x64.
Solution:
Uninstall all versions of .NET Core SDKs and Runtimes, then download and install the latest x64 SDK and Runtime version from Microsoft's webpage.
Case 2:
A .NET SDK is installed but the referenced SDK version in the current project's .csproj file does not match the installed version nor the one specified in the global.json (if exists).
Solution: Edit the .csproj file, so that the SDK versions match.
If you have or need a global.json file, make sure you set its content properly. You can read more about it here.
Finally
Don't forget to open Visual Studio, create a new e.g. Console Application and see if the Solution's files appear in the Solution Explorer window (they should). Note that existing projects may still not be working properly because their .csproj file might have wrong SDK reference - if so, you have to fix them manually.

Downgrading .NET Framework causing packages issues

I am working on a project on TFS. This project was created on someone else's PC on VS 2017 and the newest .NET framework and published to Azure.
I got the project on my PC, I have VS 2015 and I had to change the .NET framework of the project to 4.6. Everything was fine, I could make changes to the project and commit.
But when I tried to publish to Azure from my PC, I got a very unclear error:
Publish Failed
Connecting to ...
Looking for solutions online, I had to downgrade the version of the package Microsoft.Net.Compilers from 2.6.1 to 2.4.0 . And that worked !
I turned off my PC. Next day when I opened the project and ran it, I got this error locally :
Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.6.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I tried to uninstall Microsoft.ApplicationInsights and reinstall it with version 2.6.1 , but it says i need a newer version of nuget.
I am not sure how to proceed from here. I already installed all the updates in my Tools -> Extensions -> Updates but nothing changed.
Why are all these things happening to my project and how can i fix it?
PS: upgrading my VS to 2017 is currently not an option due to many exterior reasons.
Thank you.
I've gotten that error locally as well and was actually able to resolve by manually adding the file to my project folder, may be worth a shot.
Downgrading .NET Framework causing packages issues
Just like Hans said nuget packages change quite rapidly, which often require the latest version NuGet. Some new features in the package only supported by the newer NuGet (like PackageReference) or some issues fixed on the newer version. For example, install package Microsoft.EntityFrameworkCore.SqlServer 2.1.1 on Visual Studio 2015, which requires NuGet client version '3.6.0' or above.
So, the workaround for this issue is create a new project with Visual Studio 2015, copy the code from previous projects, then add those nuget package one by one to find out the reason why it needs the newer version nuget.
However, I want to talk more over about this question is that the best way to resolve this issue is to install Visual Studio 2017 alongside Visual Studio 2015. As we known, using a lower version of the Visual Studio and .net framework to open a higher version of the Visual Studio and .net framework is not recommended, it will always bring a lot of incompatibility errors and some other weird issues. Since upgrade your Visual Studio to 2017 is currently not an option due to many exterior reasons, so I suggest that you can install Visual Studio 2017 alongside Visual Studio 2015. Besides, developing the same project with different versions of Visual Studio and submitting it to the TFS server may bring many unpredictable risks.
Hope this helps.

Using C# 7.1 with 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.

LINQPad .net method description is not working after install Visual Studio 2017 Enterprise

I got an LINQPad issue after I install Visual Studio 2017 Enterprise.
You may duplicate the Issue by follow steps.
A brand new laptop with only windows 7 Pro installed (without any .net framework installed).
Install ".NET Framework 4.6.1 (Offline Installer) (x86 and x64) - (Multiple Languages)"
Install ".NET Framework 4.6.1 Developer Pack and Language Packs (x86 and x64) - (English)"
Goes to .Net Framework 4.6.1 folder "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1"
Sort files by files type
Select all XML files(these XML files are LINQPad used for code intellisense reference) for 4.6.1 total is 126 files
Right click mouse then select "Copy"
Back to Parent folder "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework"
Create a new folder named "v4.0"
Goes into new created folder "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0"
"Paste" all Selected XML file Copy to this folder
Open LINQPad (latest version), the code Intellisense and .net method description is working properly.
Install Microsoft Office Pro 2016 and SQL Server Enterprise 2014.
Open LINQPad (latest version), the code Intellisense and .net method description is still working properly.
Install Visual Studio Enterprise 2017.
Open LINQPad (latest version), the code Intellisense is working fine. BUT THE.NET METHOD DESCRIPTION IS NOT WORKING. Please check below Screen Shot for the Issue.
In my old laptop which has Visual Studio 2015 Enterprise Installed and LINQPad (latest version), then install Visual Studio 2017 Enterprise, there is no above issue. So I think LINQPad may not access .Net framework and got properly .net method description if there is only Visual Studio 2017 enterprise installed.
Is there anybody could please help me out?
Below are Original .Net Framework versions after installed Visual Studio 2017
To Make LinqPad Method Description Work Only Need Leave These Versions FrameWork

Visual Studio 2010 Command Line with Framework 2.0

Before, I was using VS 2008 command prompt and when I do
clrver
I got
Versions installed on the machine:
v1.1.4322
v2.0.50727
Now with Visual Studio 2010 command prompt I get :
Versions installed on the machine:
v1.1.4322
v2.0.50727
v4.0.30319
I want to know if there is a way to compile my C# code with the VS 2010 command line using the Framework 2.0 and not 4.0
-- Edit --
Is there another way than going in the properties of the project?
Use MSBuild command line and pass the ToolsVersion (2.0,3.0,3.5,4.0) and TargetFrameworkVersion (v2.0,v3.0,v3.5,v4.0) properties:
msbuild your.sln /p:TargetFrameworkVersion=v2.0;ToolsVersion=3.5
The UI option is described here.
You can change the targeted framework in your project settings.
http://msdn.microsoft.com/en-us/library/bb398202.aspx
(I do not yet have VS 2010 on my work machine, so I can't test whether or not support extends to .NET 2.0, though I believe it does)

Categories

Resources