.Net Core 1.1.0 NuGet packages fail to install in Visual Studio Mac - visual-studio

I'm playing around with a ASPNet.Core 1.1.0 application in Visual Studio Mac Preview and have problems updating/installing NuGet packages.
If I try to update eg. Microsoft.AspNetCore.Diagnostics from 1.0.0 to 1.1.0 it fails the download and removed the package completely. I then have to download and install the package for 1.0.0 again. Same goes for Microsoft.AspNetCore.Server.Kestrel.
Microsoft.EntityFrameworkCore I'm not able to install in any version.
Heres the exception output: https://gist.github.com/anonymous/52ceb28b8d9781835b226bcbe9d04d58
I know everything is right out of the oven, but was wondering if other people have experienced the same issues and know of a workaround/solution.

For everyone else having similar problems, here's a walk-through:
First install .NET Core 1.1.0: https://www.microsoft.com/net/core#macos
The official .NET Core 1.1.0 installer (as of when this is written) includes the .NET Core SDK 1.0.0 Preview 2.
You will need .NET Core SDK 1.0.0 Preview 3. Download it here: https://github.com/dotnet/core/blob/master/release-notes/preview3-download.md
Create a new project in Visual Studio Mac
Close the project
Open up project/src/myapp/myapp.csproj and change "netcoreapp1.0" to "netcoreapp1.1". Save and close the file.
<TargetFramework>netcoreapp1.1</TargetFramework>
Open your solution in Visual Studio Mac and compile it.
Now you will be able to update your NuGet packages to newest versions.
Should you run into problems, do a "dotnet restore" when standing in /project/src/myapp/

I reached out on Twitter and got a response from Mikayla Hutchinson, Xamarin PM at Microsoft. Check out the conversation on Twitter here.
certain NuGet packages fail to restore if they're not already in
your local cache - see https://developer.xamarin.com/releases/vs-mac/preview/vs-mac-preview1/#Known_Issues
as a workaround, you can use dotnet restore on the command-line,
which will restore and cache them
I hope this helps.

Try to change *.csproject file manually to
<TargetFramework>netcoreapp1.1</TargetFramework>
UPDATE
#egeek So, finally, I think I found some trick. I tried to add Swashbuckle Nuget package, but it failed. Then, when Visual Studio start to adding Swashbuckle, I click Forece Quit from Visual studio before the operation is complete. In *.csproj I see:
<PackageReference Include="Swashbuckle">
<Version>6.0.0-beta902</Version>
</PackageReference>
And when I again open Visual studio, click "Restore" on "Packages" folder.
Finally it not fail and added Swashbuckle correctly.

Try upgrading your nuget latest version for core 1.1 https://dist.nuget.org/index.html will resolve the issue.

Related

.NET Core Web API 5.0 build errors

Severity Code Description Project File Line Suppression State
Error NETSDK1005 Assets file 'D:\Working On\Gra\Gra\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v5.0'. Ensure that restore has run and that you have included 'netcoreapp5.0' in the TargetFrameworks for your project. Gra C:\Program Files\dotnet\sdk\5.0.100-preview.1.20155.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234
I've just create ASP.NET Core Web Application, and then when I run, I it's show message errors!
In my publish profile the Target Framework was set to NET5.0.
Changed it to NET6.0 and the problem was gone.
Update to Nuget 5.8
Clear the local cache
error NETSDK1005: Assets file 'project.assets.json' ....
Try updating NuGet.exe to the 5.8.0 version or above:
nuget update -self
if you prefer to update the nuget version in Visual Studio, just follow this steps. Then, clear NuGet cache:
dotnet nuget locals all --clear
Download Nuget
found here
Delete the 'obj' folder and re-build the project.
You're using an extremely old .NET 5 preview. ASP.NET Core Preview 1 specifically had no new features, it was essentially a version number change. There's no netcoreapp5.0 framework target any more, it's net5.0.
The latest version is 5.0 RC1 which is feature-complete and supported in production. Install it and create a new project with, eg dotnet new webapp or dotnet new webapi etc.
This version is supported by the latest Visual Studio 2019 Preview version.

Nuget package manager not working in visual studio 2019 version 16.7

Recently I have updated vs 2019 to Version 16.7. I have noticed that in this NuGet pointing to
https://api.nuget.org/v3/index.json.now a single NuGet package not downloading from this NuGet source so I have changed the source to https://api.nuget.org/v2 Still with no luck anyone has an idea what is going wrong here,is this bug in VS 2019 Version 16.7?
I have VS 2019 16.7.0 and my nuget targets https://api.nuget.org/v3/index.json (nuget v3 is there already for like 3 years) so it might be that nuget was unavailable at some point but it's definitely not a problem of VS itself as I've just tried to update few packages in my projects.
There may be other problems like the target version of your project (.Net Core project vs .Net framework package which won't work) so you might want to check that.
There is also an update to 16.7.1 so you can even try that, but this most likely won't help as the 16.7 seems to work just fine.
I added the link below in the package source and it worked for me.
http://packages.nuget.org/v1/FeedService.svc/

Build Definition Not Building After Nuget package Update In Visual Studio

I inherited a lot of stuff that is above my knowledge level, but I am the only one here that is close enough to that level to figure it out. I feel like I learn quickly, and I have been able to jump every hurdle so far without too much time taken, but I just can't figure this out!
Basically we use TFS 2015 and in that we have a build definition that goes through an agent on a remote computer (that I can remote into).So, one of the developers checked in code with an updated NuGet package (Newtonsoft.Json) and it broke the build. The files and everything build locally just fine, but the build bot is broken.
I have a screenshot on imgur for a little context in my build definition and the webhook we use to send the notification in slack links to a an error page that tells me "error: Build Not Found" so I am all kinds of confused and I can't find anything online that can help me.
EDIT:
In my build logs I got this error
Error CS0246: The type or namespace name 'DataSourceRequest' could not be found (are you missing a using directive or an assembly reference?)
All of my other branch builds work and the only difference is that I updated the nuget package. Is there any way for me to upgrade the nuget package in the build agent?
Screenshot of Build Definition:
Build Definition Not Building After Nuget package Update In Visual Studio
AFAIK, the reason of this issue may be that you upgraded the package Newtonsoft.Json to version 9.01 or higher.
Starting from Newtonsoft.Json 9.0.1, this package supports the targets framework .NETStandard:
https://www.nuget.org/packages/Newtonsoft.Json/9.0.1:
Which is supported by NuGet 2.12 for Visual Studio 2013:
NuGet 2.12 Release Notes
Full NetStandard and NetCoreApp support for VS2013.
So, to resolve this issue, you should make sure the nuget.exe version is higher than 2.12 and the Visual Studio version is high than 2013.
Besides, as we know, Visual Studio are backwards compatible. Meaning we could use the lower version Visual Studio to develop the project and we could build it with a higher version of Visual Studio on the agent. But if the other way around, develop it with higher version, build it with lower version on the agent, we may encounter some issues due to compatibility. So, If we keep that the Visual Studio version on the agent is higher than the version you are developing, it would be better.
Hope this helps.

Latest version of nuget package still not up to date

We are using our own nuget server on the local network.
I've got a dotnet standard 2.0 library which I'm packaging via nuget. Currently it's at 1.0.5.4 (both File version and Assembly version).
However when I install it in another solution it's missing a property that I added in the latest version increment. When I F12 on a class of that nuget it reads at the top:
#region Assembly lib-mycode-async, Version=1.0.5.1, Culture=neutral, PublicKeyToken=null
// C:\Users\{Username}\.nuget\packages\lib.mycode\1.0.5.4\lib\netstandard2.0\lib-mycode-async.dll
#endregion
In the nuget Manager GUI of Visual Studio it says 1.0.5.4 everywhere. I uninstalled the nuget from all projects of the solution,
uninstalled any other package that used that particular nuget
did Update-Package -reinstall to reinstall all nuget packages in the solution
closed and reopened Visual Studio (2019 but also remember having had this with 2017)
rebuild the nuget packages
cleaned the nuget package cache in Options > Nuget Package Manager > General > Clear All NuGet Cache(s)
Why does it appear to be up to date everywhere and still I cannot use the latest code changes?
While writing the question I followed the path in the meta data.
The .dll file the path points to indeed had the version 1.0.5.1 so I deleted the entire folder lib.mycode in C:\Users\{Username}\.nuget\packages.
I rebuild my solution, closed VS 2019 and reopened the solution.
Now the folder was back but with the right version. The code was finally there which I added in the latest version of my nuget package.
I really thought that this would have been taken care of by the last point I tried out in the question above!

Visual Studio for Mac does not get past "Add packages"

I am trying out Xamarin Forms on Visual Studio for Mac.
When I create a new project, I see VS is trying to add packages to the solution, but every single time- it fails at the same place...
Here is the Package Console output:
https://drive.google.com/open?id=1-KfdWC2hub4YuEOHfJ_LICL86o6zkecytmMAi0emDeQ
On this new project, after the package installer fails, it always fails to build with the default assets:
Is it possible other dev environments are affecting Visual Studio?
Is there a more stable way I can use Xamarin forms on a Mac?
Thanks in advance!
One of the errors I see in your Package Console is:
Could not install package 'Xamarin.Android.Support.v4 23.3.0'. You are
trying to install this package into a project that targets
'MonoAndroid,Version=v2.3', but the package does not contain any
assembly references or content files that are compatible with that
framework.
NuGet looks at your project's target framework and version to see if the NuGet packages are compatible. As far as NuGet is aware your project is targeting MonoAndroid version 2.3. Check what you have selected as the Compile using Android version in the project properties and ensure that it's compatible with the package you want to add.
Also, a "more stable" way to use Xamarin Forms on a Mac is not available unless you want to try Xamarin Studio but that is almost the same as Visual Studio for Mac (which is based on it).

Resources