How to use DotNet.Contracts NuGet package? - c#

Could someone shed some light on how to use the DotNet.Contracts NuGet package in Visual Studio 2015 and 2017? Is it the only component required to use Code Contracts in Visual Studio???
Do I still need to install Contracts.devlab9ts.msi??? When trying to install Contracts.devlab9ts.msi, I got error 'Extensions' is not a valid short file name. This occurs on my Windows 10 dev machine, with latest Windows updates.
If we still need to install Contracts.devlab9ts.msi, what's the purpose of the NuGet package?

You just need to install the DotNet.Contracts NuGet Package in your project, because this package contains all Code Contracts related files.
Please refer to:
https://github.com/Microsoft/CodeContracts/issues/13
The Contracts.devlab9ts.msi could be installed on my Windows 10 build 10240 successful. If you still want to install Contracts.devlab9ts.msi for your Visual Studio, please check your Windows 10 version and make sure your Windows 10 dev has installed all updates.

Related

when create xamarin.android app has error

Hello When I create a Xamarin app on Android, I encounter the following errors after creating the application
1-failed linking file resources. 2-attribute layout_behavior (aka
com.companyname.app2:layout_behavior) not found.
After seeing this problem, I saw the used version of Android, which was Android 11, and changed it to version 8.1.
The errors were fixed, but it showed me new errors
Package Xamarin.Google.Android.Material 1.0.0.1 is not compatible with monoandroid81 (MonoAndroid,Version=v8.1). Package Xamarin.Google.Android.Material 1.0.0.1 supports: monoandroid90 (MonoAndroid,Version=v9.0)
Package Xamarin.AndroidX.AppCompat 1.2.0.5 is not compatible with monoandroid81 (MonoAndroid,Version=v8.1). Package Xamarin.AndroidX.AppCompat 1.2.0.5 supports: monoandroid90 (MonoAndroid,Version=v9.0)
Because the program has an error, I can not use nuget
And I guess Visual Studio builds my project with Android 11 libraries.
But I do not know how to change this
Please help me to fix the errors
This problem was not resolved and eventually I had to replace Windows and reinstall Visual Studio
And after reinstalling Visual Studio, I no longer had this problem

Enable C# 6.0 in Visual Studio 2012 on an offline PC

I have read the answers at
C# 6.0 Support in Visual Studio 2012
however it's not clear how to get it done on an offline PC.
I have downloaded the latest stable version of the C# compiler available at
https://www.nuget.org/packages/Microsoft.Net.Compilers/
but I'm clueless of what do I do with the dowloaded nuget package, best I could do was rename it to .zip and extract it but I got stuck again not know how do I reference that in Visual Studio 2012.
Also I have no idea how to upgrade Nugetto the latest version (as outlined in that answer) before I do the other steps?
You will have to use a computer that have internet access to retrieve the nuget package and copy it the the offline computer.
Visit Nuget Site for the package you need .https://www.nuget.org/packages/Microsoft.Net.Compilers/
Click the download package link on the page
Use the nuget command-line interface to add the project to project file. For example: nuget add -Source some/directory my.nupkg
Put your downloaded packages in a folder and use it as your package source.
https://learn.microsoft.com/en-us/nuget/hosting-packages/local-feeds
You need to add the nuget package use the package manager console.
Install-Package SomePackage -Source C:\PathToThePackageDir\
Hope this helps.

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.

Can't install SignalR client in Xamarin.Forms

Here's my environment:
Visual Studio 2017 15.1, running on Windows 10, which runs in VM on MacOSX.
In VS I installed API23 Android SDK.
On MacOSX: Xamarin Studio 6.3
Both, XS on Mac and VS on Windows have Xamarin.iOS 10.8.0.175
So, as you can see it's not the latest configuration, BUT it's pretty new. It was the latest around April '17. I have to mention that I installed SignalR a year ago.. so it worked. I don't know why I can't install it now. I'm getting this error during installation from nuget:
Error:
Could not install package 'Microsoft.AspNet.SignalR.Client 2.2.0'. You
are trying to install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile111', but the package does
not contain any assembly references or content files that are
compatible with that framework. For more information, contact the
package author. 0
EDIT:
Here are targets of my PCL (I'm not sure what the profile is this):
Does that mean I have to add Silverlight 5.0?

Nuget version not correct?

I have a project that i cannot compile. When i try to do so I get the following error:
The 'Microsoft.Bcl.Build 1.0.14' package requires NuGet client version '2.8.1' or above, but the current NuGet version is '2.7.41115.310'.
Normally this would be simple. After searching I found this guide:
http://www.daimto.com/package-requires-nuget-client-version-x/
That explains how I can upgrade my Nuget client version. However, when i follow those steps, I find that I am already using the latest version of Nuget: 2.8.5
For some reason however, Visual Studio 2013 Ultimate is using an older version, and I don't understand why.
My install of Visual Studio Ultimate 2013 is a fresh install, after unninstalling Visual Studio for Web Express 2012. The previous version was giving me a considerable amount of problems and so I deleted it and moved on to 2013. I wonder if some cofig files were passed through, but I cant be sure.
How can I fix this problem?
From Tools → Extensions and Updates → Installed, uninstall “NuGet Package Manager” and install it again.
So, after searching around I found no answers, so I decided to look into the project folders. It happens that I have the main version of NuGet.exe, 2.8.5 in main folder, but the project was nowhere near that main folder.
This way, when I downloaded the project it simply used the NuGet version pulled from TFS (or so I assume), and that was the problem - that verison was Nuget.exe 2.7.4.
After replacing the "Nuget.exe" files (found in /.nuget folder of the project) the project finally compiled and everythign started working again.
You can also try update Nuget Package Manager directly from Tools > Extensions and Updates
In my case, a pending update of Visual Studio fixed the nuget version.
The update was the "Update 5" for VisualStudio 2013.
The update was listed under the menu Tools → Extensions and Updates, on the tab Updates.
I was getting this error from a recently cloned branch, but (in contrast to the above solution) found that my Nuget version in the project directory was the same as that in my solution directory.
I solved this by right clicking on the solution and Managing Nuget Packages for the solution. The Nuget dialog that popped up said that packages were missing and asked me to restore them. Once downloaded, the project built successfully.
I had the same issue when trying to install System.Net.Http and it said the nuget version needed to be version 3.0 or above. I tried few things but in the end, used Tools and Manage Nuget Packages and did a search and tried to install it from there when it said exactly the same thing - wrong version of nuget, but it popped up with an upgrade Nuget button too!
Hope this helps someone
Simply reinstall nuget in visual studio

Categories

Resources