dotnet new --install is looking at wrong NuGet server - nuget

Running:
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
Generates the below error:
C:\Program Files (x86)\dotnet\sdk\1.0.4\Nuget.targets(97,5): error : Unable to laod the service index for source https://MYNugetFeed.pkgs.visualstudio.com/_packaging/Project/nuget/v3/index.json. \r [C:\Users\me\.templateengine\dotnetcli\v1.0.4\scratch\restore.csproj]
C:\Program Files (x86)\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Response status code does not indicate success: 401 (Unauthorized).
So my questions is why is it looking at that NuGet feed and not the standard (assuming that's where these templates are) and how do I change the configuration for dotnet cli? I know this is environment related in some way.

Cause
When you set up NuGet servers in Visual Studio (and perhaps other tools), they are saved on a per-user basis in NuGet.config. Dotnet new -install tries to make use of them. Unfortunately, one of my nuget servers (Telerik) requires authentication, and it failed so hard that it stopped all the other sources from even being tried.
Solution
On both Windows 10 and 8.*, you can find NuGet.Config here:
Go to C:\Users\[User Name]\AppData\Roaming\NuGet\NuGet.Config
Under <packageSources>, there will be a list of servers, like this:
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="REDACTED" value="http://REDACTED:8080/guestAuth/app/nuget/v1/FeedService.svc/" />
<add key="REDACTED" value="http://REDACTED/nuget" />
<add key="Telerik (Kendo)" value="https://nuget.telerik.com/nuget" />
</packageSources>
To make this work, I reduced that down to the core nuget.org server:
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
...And then template installation started working.

It sounds like your computer has a global nuget configuration that points to that feed. You can change that behaviour for a specific directory and it's children by creating a new nuget.config file.
You can find out how the local files override global ones on the Configuring Nuget Behavior page of the Nuget documentation.

I had, presumably, the same problem Brian MacKay encountered with Telerik. However, I am actively working a project that needed the Telerik source, so I wasn't keen to remove everything from my Nuget.Config
However, by specifying the specific nuget source in the command, I was able to install the desired templates - in my case IdentityServer4 templates. So this command worked:
dotnet new -i IdentityServer4.Templates --nuget-source https://api.nuget.org/v3/index.json
Assuming that the OP is correct and the templates mentioned are in the standard Nuget registry, I imagine a similar call would work there.

Related

How do I get Hellow Quantum world to run in Visual Studio 2019

This is my first attempt at Q#. I followed the instructions here: How do I get the missing dependencies? Please see my screen shot
https://learn.microsoft.com/en-us/azure/quantum/install-command-line-qdk?tabs=tabid-vs
Have you tried just building the program? Nuget dependencies are typically downloaded the first time you build the program?
Looks like you're using the most recent version of the QDK (0.17.2105.144881), so you can open your .csproj file and confirm that it's using it. You should see this on the first line:
<Project Sdk="Microsoft.Quantum.Sdk/0.17.2105144881">
You can also confirm that the NuGet.config file in your machine has the public feed in it:
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
If you still get NuGet restore issues, I would also recommend installing .Net Core SDK 3.1.409 (Link). I see that you are using .Net 5.0, but you can have multiple versions side by side.
I hope this information is useful.
It seems like there is an issue with NuGet. If you in Visual Studio select Tools=>Nuget Package Manager=>Package Manager Console and in that write the command: dotnet restore.
And you then get an error similar to:
The package is missing the required nuspec file. Path:
C:\Users\x\.nuget\packages\x.x.x
Then there is something broken with your local NuGet cash, empty it by removing everything inside the packages folder. and then run the command dotnet restore again.
also includes the error messages, since image-texts isn't searchable (so that others also can find this):
No namespace with the name "Microsoft.Quantum.Canon" exists.
No namespace with the name "Microsoft.Quantum.Intrinsic" exists.
No type with the name "EntryPoint" exists in any of the open namespaces.
No identifier with the name "Message" exists. Assets file
'c:\User…\obj\project.assets.json' not fount. Run a Nuget package
restore to generate this file.

Hosting private nuget server issue

I have setup my own nuget feed and have hosted that on our dev server.
When I try to push my packages from my local machine to dev machine as below:
dotnet nuget push C:\MyProjects\Common.2.0.0.nupkg -k myapi -s https://mydev.com/AENuget/
I get the error as:
Response status code does not indicate success: 405 (Method Not Allowed).
Now I have read and tried many settings like adding
<remove name="WebDAV" /> <remove name="WebDAVModule" />
Giving permissions to my nuget packages folder, adding app pool account but still I am not able to resolve this issue.
Secondly instead of pushing if I just copy my nuget package file to the package folder being hosted in our dev server and then in visual studio I add the new server source I get the below error:
[Package Source] The V2 feed at 'http://mydev.com/AENuget/Search()?$filter=IsLatestVersion&searchTerm=''&targetFramework=''&includePrerelease=false&$skip=0&$top=26&semVerLevel=2.0.0' returned an unexpected status code '404 Not Found'.
So looks like neither the push from nuget nor the copy is working. Looks like some permission issue which I am not able to resolve.
Would appreciate if someone can provide any inputs to this.
FYI: This works fine if I host this on my local machine.
The problems you are having seem to indicate you are having issues with the NuGet.Server and the system itself. These can be problems with the firewall, hosting configuration (IIS), or a wide variety of problems.
If you are on a very small team, you might just create a shared folder on a network server (with read/write access for the team). You can add the package source to Visual Studio by following this article. The source will be the UNC path to the directory (e.g. \\servername\path\to\nuget\folder).
NuGet.Server is a package provided by Microsoft and NuGet. This is used widely so I do not believe you have a problem with the package. If you encounter a specific problem, we may be able to help.

Not able to get MongoDB.driver nuget for Webapi project

I am new to MongoDB and is trying to get this new Database connected with my Web api application ..But i am not able to add MongoDB.driver nuget for my Webapi project.Please refer screen shot.
My search is struck on this window for like forever.,have even restarted my project for a couple of times now.
I also tried installing this package through
PM>Install-Package MongoDB.Driver
But then this is shown
Am I doing something wrong ..?
i tried opening this url"api.nuget.org/v3/index.json"...but it says this site cant be reached..what does that mean?
Since the you could not open the url in browser directly, there should be some internet limitations in your internet environment. If you are work in the company, I suggest you contact your office IT to confirm whether they add any limitations and whether used any proxy. If they are using some proxy, you need to set the proxy settings in NuGet.Config file which store in C:\Users\user name\AppData\Roaming\NuGet as below settings. Detailed information please refer to the Proxy settings part in Nuget Config Section & Nuget Proxy Settings.
<add key="http_proxy" value="host" />
<add key="http_proxy.user" value="username" />
<add key="http_proxy.password" value="encrypted_password" />
Besides, you can chech the proxy in your machine: Open "System Properties" > Advanced > Environment Variables. Find the http_proxy var (in System variables), select and delete it.

Is there a system that I can use to update my projects on my VPS?

Hey guys, So I recently got a VPS, just so I can start gaining experience. But I'm looking for a service/program where I can code on my PC, then when I'm done, I run a script or do a command or something to have it updated to my VPS.
I thought I was looking for Git, but apparently git does not do what I'm looking for.
Any suggestions?
Windows or Linux?
On Windows, there's a host of tools.
First of all you code. Visual Studio is the most common. You get a sln-file and a batch of *.*proj-files.
When talking about deploying to remote servers, often a continuous integration server is used. We are using TeamCity (http://www.jetbrains.com/teamcity/). Download it locally, install and create a new project, selecting the "SLN-runner". Point it to the sln file of yours.
When you want the deployment part working, create a small build file such as "MyProj.build", that contains something along the lines of
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="BuildProject"
InitialTargets="CheckRequiredProperties"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0">
<Target Name="BuildProject">
<Message Text="Starting $(Configuration) build. Web site publish location $(OutputWebSite)" />
<MSBuild Projects="$(SolutionPath)"
Targets="Build"
Properties="BuildOutputPath=$(BuildOutputPath);
BuildOutputPathBin=$(BuildOutputPathBin);
Configuration=$(Configuration);
BuildConstants=$(BuildConstants);
MSBuildTargets=$(MSBuildTargets);
TargetFrameworkVersion=$(TargetFrameworkVersion);
TargetFrameworkProfile=$(TargetFrameworkProfile)">
...
Where SolutionPath points to your sln-file.
You will then update the TeamCity config to point to MyProj.build instead, using the MsBuild runner.
Then you need a way of having TeamCity upload everything to your server. Powershell is a nice scripting environment that can run .Net code, but you'd be invoking it through MsBuild...
Something like this
http://community.bartdesmet.net/blogs/bart/archive/2008/02/16/invoking-powershell-scripts-from-msbuild.aspx
And then you can script with MsDeploy accross to your server:
http://blogs.iis.net/jamescoo/archive/2008/08/21/using-msdeploy-in-powershell.aspx
"rsync" or "scp" tools may be useful

Crystal Reports images not visible in web viewer

I have some Crystal Reports (V10) in an application (.NET 1.1) I inherited that is deployed in four "identical" environments. In three of the environments, they are working fine. In the fourth, the chart graphics are not visible in the web viewer. They are visible if you export the reports.
The IT guys swear everything is exactly the same in all four environments and have kicked the problem back to me to solve. I'm not sure how I'm going to do that since I can't get to the servers to check anything for myself. But I don't see how this can NOT be an environment issue.
It seems to me that Crystal has the necessary permissions to write the file and to retrieve it to render the export versions of the report, but the ASP WP can't access the graphic file when the page is rendered.
Thanks for any suggestions you might have to help me!
RESOLUTION
From the IT guys: "We had to change the “Execute Permissions” on the CrystalReportsViewer10 folder within IIS from “Scripts only” to “Scripts and executables”. All of the other sites have only “Scripts Only” and they’re fine."
I could resolve this issue in dev enviroment adding next keys (handlers) to web.config:
<system.webServer>
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
</handlers>
</system.webServer>
<system.web>
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
</system.web>
There needs to be an IIS virtual directory called something like "CrystalReportViewers115". I think that the exact name changes between versions. This needs to be visible to your ASP.NET user. Start looking at the environments that work and see if they have this virtual directory installed, and compare it to the one on the failing environment. As another check, you should be able to enter in the URL for the images into a browser and see them. To find out the URL, right click on the picture and select "Properties". For example:
http://localhost/crystalreportviewers/images/toolbar/export.gif
You should see the picture when you browse directly to the URL.
Go to Start->Programs->Microsoft Visualstudio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt
and type
aspnet_regiis -c
This will automatically copied the corresponding files...
Add the aspnet_client folder in the source folder of the site. Example:
C:\inetpub\wwwroot\myapplication\aspnet_client\system_web\4_0_30319\CrystalReportWebFormViewer4
I recently experienced this very issue: although my resolution was a little different:
I tried setting the handler in the web.config but that didn't fix it.
I tried setting scripts & executables in IIS but that didn't fix it.
Once I went into the C:\Program Files\Common Files\Crystal Decisions\2.5\crystalreportviewers10 folder and turned off custom errors I could see the error was coming from an access denied issue on C:\Windows\Temp\
The solution was then to not and handlers or alter IIS to run scripts and executables, it was to allow the Network Service to read permission on C:\Windows\Temp\
EDIT:
Think I've found another solution which doesn't require permission changes... just set a virtual directory for aspnet_client; the level at which you select this will very much depend on your IIS layout.