I have created a multi-project template and when creating a new project I'm having success installing nuget packages into all my projects when it comes to regular release versions, but I'm trying to grab signalr's prerelease version and it can't find the version '1.0.0-alpha2'. I assume because its a prelease. Although I can grab it from within VS's PM prompt using :
Install-Package Microsoft.AspNet.SignalR.JS -version 1.0.0-alpha2
...Is there something different with the API that I need to do to grab it or what am I doing wrong?
Example within my project templates wizard
var componentModel = (IComponentModel)services.GetService(typeof(SComponentModel));
IVsPackageInstaller installerServices = componentModel.GetService<IVsPackageInstaller();
installerServices.InstallPackage("http://packages.nuget.org", project, "Microsoft.AspNet.SignalR.JS", "1.0.0-alpha2", false);
Okay this works with https://www.nuget.org/api/v2/ as the target, not the older v1 at packages.nuget.org. Found out v2 with fiddler
Related
When I try to add a NuGet package via the dotnet cli I get an error that it can't access one of my custom NuGet sources. Is there a way to say "I don't care, restore from where you can"?
McMaster.Extensions.CommandLineUtils clearly it exists in NuGet.org and it finds it but then stops b/c it can't access a custom source 🤷♂️.
PS c:\Temp\blah-project> dotnet add package McMaster.Extensions.CommandLineUtils
info : Adding PackageReference for package 'McMaster.Extensions.CommandLineUtils' into project 'c:\Temp\blah-project\blah-project.csproj'.
info : Restoring packages for c:\Temp\blah-project\blah-project.csproj
info : GET https://api.nuget.org/v3-flatcontainer/mcmaster.extensions.commandlineutils/index.json
info : OK https://api.nuget.org/v3-flatcontainer/mcmaster.extensions.commandlineutils/index.json 147ms
error: Unable to load the service index for source https://myinstace.pkgs.visualstudio.com/_packaging/Blah/nuget/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
The dotnet command has the option to specify --source. This allows you to only restore packages from a specific location, in this case you'd want to use
dotnet restore --source https://api.nuget.org/v3/index.json`
This should pull the packages down to your local NuGet store and solve the problem on your machine.
In order to add the package to your project you may need to manually add a <PackageReference> to your project like
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.6.0" />
Then running the restore command above will get the package for you.
As a more-permanent fix, you should put a nuget.config file in the root of the project/repository where you specify the package sources for that specific project. There are settings that you can set to override your system's global nuget configuration/sources. See more information on nuget.config. You can create a starting nuget.config in your repo with dotnet new nugetconfig
while restoring packages, dotnet make a call to all the package sources to get the package and uses the one that responds first.
In your case, because of some authentication issue it is not able to access that source. That source can be disabled using the below command and then try to pull the package.
dotnet nuget disable source <NAME> [--configfile <FILE>]
You might be able use the --ignore-failed-sources option.
I'd recently encountered similar issues when having authentication problems on a private feed, this allowed me to install the packages (was actually a tool using dotnet tool install) and address my auth issue at a later date.
See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-restore for more info and options.
SQL Lite states that its added support for Xamrian Forms and .net standard and yet when I rebuild my project all references disappear what it the correct library I need to get SQL lite working in .net standard 2.0 I am using it to sync between a mobile app and the server.
public async Task SyncAllDeliverys()
{
Task<string> callTask = Task.Run(() => GetDeliverysFromAPi());
// Wait for it to finish
callTask.Wait();
// Get the result
string content = callTask.Result;
//Sends a GET request to the specified Uri and returns the response body as a string in an asynchronous operation
deliverysItems = JsonConvert.DeserializeObject<List<DeliverysItems>>(content); //Deserializes or converts JSON String into a collection of Post
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(dbPath);
await conn.InsertAllAsync(deliverysItems);
}
As you see here my project is .net standard 2.0
Edit 2
To show the correct version that I have installed instead of the incorrect one I showed in the first graphic.
Edit 2
It would appear that this is a known bug and xamrian has submitted it as such in 2019 visual studio.
https://github.com/xamarin/Xamarin.Forms/issues/5983
You are looking at the wrong description of dependencies. The dependencies in the first screenshot(you circled in the right bottom) belongs to sqlite-net-pcl instead of SQLite.Net-PCL.
Package 'SQLite.Net-PCL 3.1.1' was restored using
'.NETFramework,Version=v4.6.1'.
You can try uninstall and install sqlite-net-pcl nuget, clean and rebuild your project.
what it the correct library I need to get SQL lite working in .net
standard 2.0
Use sqlite-net-pcl is the right way. (The fourth library in your screenshot).
There are a number of NuGet packages with similar names, the correct package has these attributes:
Created by: Frank A. Krueger
Id: sqlite-net-pcl
NuGet link: sqlite-net-pcl
Refer: databases
I have a very simple WebAPI 2 controller running on .NET Framework 4.6.2, that looks like this:
[RoutePrefix("Invitations")]
public class InvitationsController : CqrsApiController
{
[HttpPost, Route("Clients/{id:long}/Actions/Cancel")]
public IHttpActionResult PostClientInvitationCancel(long id, [FromBody] ClientInvitationCancelCommand command)
{
Execute(command);
return SeeOther("Invitations/Clients/{0}", id);
}
}
and am trying to write an NUnit test for it, like this:
[TestFixture]
public class WhenExecutingAValidCommand
{
[Test]
public void ItShouldReturnARedirect()
{
var dispatcher = Substitute.For<ICqrsDispatcher>();
var urlHelper = Substitute.For<UrlHelper>();
urlHelper.Link(Arg.Any<string>(), Arg.Any<object>()).Returns("https://tempuri.org/");
var sut = new InvitationsController(dispatcher);
sut.Request = new HttpRequestMessage();
sut.Configuration = new HttpConfiguration();
sut.Url = urlHelper;
var response = sut.PostClientInvitationCancel(1, new ClientInvitationCancelCommand());
response.Should().BeOfType<SeeOtherRedirectResult>();
}
}
```
However, when I run the test, I get the following error:
System.MissingMethodException : Method not found: 'Void System.Web.Http.ApiController.set_Request(System.Net.Http.HttpRequestMessage)'.
at ApiProjectTests.InvitationsControllerTests.WhenExecutingAValidCommand.ItShouldReturnARedirect()
The same code seems to work fine in similar projects based on .NET Framework 4.5.1, so I'm wondering if there's some sort of DLL hell going on here. System.Web.Http is using Microsoft.AspNet.WebApi.Core.5.2.3, whereas System.Net.Http is coming from the GAC (well, C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Http.dll to be more precise).
Update: if I try to debug into the unit test, the error occurs before I even enter the method. So although VS2017 compiles the tests just fine, when the test runner fires up, then everything falls apart. Sounds more like DLL hell to me.
Update 2: if I comment out the setting of the request, then I can debug into the test method. If I then put in a breakpoint, and then use the Immediate window to directly set the request property, it works, and there is no Method not found error. I also disabled Resharper and used VS2017's Test Explorer to run the tests, in case R# was caching something, but it made no difference.
It looks like my problem is indeed DLL hell, more specifically the DLL hell referenced by https://github.com/dotnet/corefx/issues/25773. The issue is caused by other NuGet packages that contain references to the newer version of System.Net.Http (4.2.0.0). The current solution appears to be to add a binding redirect to downgrade the assembly version to the expected version (4.0.0.0), but so far that has not helped me.
The solution that did work for me was to install the latest NuGet package of System.Net.Http, and use assembly binding redirects in my test project to ensure that it used the 4.2.0.0 version instead of 4.0.0.0.
This is often caused by early versions of nuget packages targeting .NET standard, which have dependencies on OOB ("out-of-band") packages. OOB packages are a kind of polyfill for dlls that are part of .NET framework but not .NET standard. Here is a very good explanation of what happened. In my case, the following helped:
I identified the nuget package that had a dependency on the system.net.http 4.2.0 nuget package, and upgrade that package.
The dependency was no longer present in the upgraded package, so i could uninstall the system.net.http 4.2.0 nuget package.
The upgraded package of course still expects the reference to the system.net.http 4.0.0 assembly, so in case of doubt, you may reinstall the upgraded package to make sure that the assembly reference is in your *.csproj file.
Some weeks ago, I followed this tutorial to get started with dotnet core + vue.js.
The steps to install the template were:
Install the SPA (Single Page Application) templates provided by Microsoft:
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
To get started and create a new Vue project, simply run the following commands on the console:
mkdir new-project
cd new-project
dotnet new vue
It worked perfectly (I repeat: that was some weeks ago).
Now I've repeated the same steps in the same machine and it says "There are no templates that match the name of the input template: vue" =>
Have the vue.js template been discontinued during the last weeks? Or am I doing something wrong?
After other comments saying it was working for them, and knowing that it worked for me some weeks ago, I've finally figured out what is going on:
On my "Available package sources" (NuGet config) in VS2017, I had the nuget nuget repository from work [work-repo]. I have to connect via VPN to be able to access it (and I wasn't during my tests). I didn't have it connected some weeks ago when the whole process worked perfectly.
Now, when I was executing dotnet new --install Microsoft.AspNetCore.SpaTemplates::*, the first lines were informing me that "I am not able to connect o [work-repo]". But then it seemed to continue as if nothing happened, and I ignored it because I didn't see it as something that would have anything to do with "not seeing vue".
Once I removed [work-repo] from the sources list, I have been able to see the "vue" template again. I have installed it via dotnet new vue and it works perfectly.
tl;dr: If you have "Nuget package sources" that are not accessible at the moment, the process "Install the SPA templates provided by Microsoft" doesn't work.
I had the same issue. In my case, the issue occured after installing Visual Studio 2019. After struggling for a while I found out that
the NuGet V2 package source was completely missing.
After going to Tools -> Options -> NuGet Package Manager -> Package Sources, adding https://www.nuget.org/api/v2/, the vue-template appreared after running that command:
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
I similarly found this wasn't working, and the problem was also having a private repository (that needed authentication rather than being completely inaccessible). The simplest solution for me was to list the nuget packages using 'nuget sources', check the name of the private repository, use 'nuget sources Disable -Name [privatereponame]' to temporarily disable the repo, then run 'dotnet new --install Microsoft.AspNetCore.SpaTemplates::*' to install the new templates, and finally 'nuget sources Enable -Name [privatereponame]' to re-enable the private repo that was causing the problem.
I had the same problem and it was Telerik source/package causing the issue. Once I removed iy from the "Available package sources" (just like Xavier suggests), the SpaTemplates install completed without error
Its so simple: just run
dotnet new search vue
then follow the instruction
and then select a template, enjoy
i am trying to install MVVMCross plugin in UWP project but it seems to fail.
in the PCL it seems to be working fine, but in the UWP I'm expecting that the plugin will create a Bootstrap folder and it doesn't happen.
I even started a new project from scratch named it "TipCalc.WindowsUWP", installed the MVVMCross and then the JSON plugin using NuGet and nothing happens.
the output of the plugin installation looks fine:
Restoring packages for 'TipCalc.WindowsUWP'.
Restoring packages for C:\Users\kayce\Documents\Visual Studio 2015\Projects\TenBisServer\MvvmCross\TipCalc\TipCalc.WindowsUWP\project.json...
Package restore completed successfully for 'TipCalc.WindowsUWP'.
Successfully installed 'MvvmCross.Plugin.Json 4.2.3' to TipCalc.WindowsUWP
========== Finished ==========
what I am missing ?
This is expected behavior, as a UWP project uses a project.json (NuGet 3) template. Currently all additional content and scripting specified in the NuGet package with have no affect on your project when including a package (See Changes affecting existing packages).
You will have to manually add the bootstrap folder and relevant plugin bootstrap .cs file, or you can register the interface and implementation of the plugin in your Setup.cs.
Bootstrap Approach:
using MvvmCross.Platform.Plugins;
namespace <<YOUR_NAMESSPACE>>.Bootstrap
{
public class JsonPluginBootstrap
: MvxPluginBootstrapAction<MvvmCross.Plugins.Json.PluginLoader>
{
}
}
Setup.cs Approach:
protected override void InitializeLastChance()
{
base.InitializeLastChance();
Mvx.RegisterSingleton<IMvxJsonConverter>(new MvxJsonConverter());
}