Nuget Package Source is not prompting for credentials - nuget

I've added a NuGet Source. It needs credentials but when I'm installing a package using install-package packageName nothing happens.
I tried the same steps on other PC and it works.
I'm using Visual Studio 2017 Professional.
Could someone please help me with the issue?
My NuGet sources

This is riddiculous that it does not prompt for credentials.
To make it work I had to do the following:
Download nuget.exe from Nuget download site
Remove my old package source
Go to NuGet Package Manager for Solution->Settings
Delete your Package Source
Run Command Line
Go to nuget.exe
Add package source with plain password in the command
nuget.exe sources Add -Name "YourPackageName" -Source "YourPackageAddress" -Username YourUserName -password YourPassword -StorePasswordInClearText
Done... phew

If Visual Studio does not prompt for credentials but the logging Output shows that you did not authenticate correctly, then go to
Control Panel\User Accounts\Credential Manager
and click "Windows Credentials".
You can remove stored credentials for nuget/github there. If they become invalid - for example because you regenerated a token - Visual Studio does not prompt to overwrite the invalid credentials, but after removing the credentials and restarting Visual Studio you do get the prompt.
I've documented more troubleshooting related to the NuGet.Config in this issue:
https://github.com/verybadcat/CSharpMath/issues/168
Source for solving this specific problem:
https://support.microsoft.com/en-us/help/4026814/windows-accessing-credential-manager (I found this via: https://developercommunity.visualstudio.com/content/problem/98692/nuget-package-source-is-not-prompting-for-credenti.html)

After many attempts to set password, reset password or whatever the only thing that helped me was adding this section to the NuGet.Config (located on the .nuget folder for the main solution)
NuGet.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="false" />
</solution>
<packageSourceCredentials>
<MySourceName> <!-- Name of nuget package source -->
<add key="Username" value="..." />
<add key="ClearTextPassword" value="..." /> <!-- This is for normal password-->
<!--if encrypted use key="Password"-->
</MySourceName>
</packageSourceCredentials>
</configuration>
One important notice - for any change to this file to take effect I had to restart VS

Remove the source from the Nuget Package Manager and add it with a new name.

Credentials popup might be not coming because you have earlier entered some other credentials or some other credentials is stored against the NuGet Package. You can goto Credentials Manager in your PC and check for all NuGet Credentials.
If you found any, Please remove them from there. And, then try to restart Visual Studio and enter the package source and Url again. This time you will get the popup to add credentials for sure.

Related

Doing a local NuGet package installation but getting the error - Unable to get repository signature information

I'm trying to do an offline NuGet package installation by following the answer by Samuel Jack here:
Text
1. Add the files to a folder called LocalPackages next to solution
2. Create a file called NuGet.config next to solution file
The .nupkg files are stored locally and installed using NuGet Package Manager but I'm getting this error - "Unable to get repository signature information for source https://api.nuget.org/v3-index/repository-signatures/5.0.0/index.json. Response status code does not indicate success: 403 (Forbidden)."
I don't understand why the package manager needs to get repository signature information from the internet when I'm trying to do an offline installation. Internet connection is blocked in my server & that's why I'm getting 403 error.
How do I install the NuGet packages locally without getting the error?
How do I install the NuGet packages locally without getting the error?
You can try the following steps:
Solution
1) please make sure that you have these xml nodes in the new Nuget.config file:
<disabledPackageSources>
<add key="xxxxx"(the source name of api.nuget.org/v3-index/repository-signatures/5.0.0/index.json) value="true" />
</disabledPackageSources>
2) clean all nuget caches or delete the packages folder under C:\Users\xxxx\.nuget\packages.
3) If you add the new Nuget.config file in your solution , it cannot work immediately, it needs a restart. You should restart VS and then open your project, and after that, it can work.

Reset NuGet credentials in VS2017

I've specified wrong credentials, which then were remembered. How do I make NuGet forget it?
As SayusiAndo guessed, the credentials were stored in Control Panel -> Credential Manager. After removing of which everything works fine.
UPDATE:
Two gotchas (as #Jurri mentioned in the comments):
There may be two credentials to delete (Windows and Generic). The generic one, in my case, had "VSCredentials_" prefix.
Restart VS.
I ran into a situation where the NuGet credentials I entered into Visual Studio were not in my Credential Manager. Deleting the package source in Visual Studio, closing Visual Studio, reopening Visual Studio, and recreating the package source allowed me to re-enter my credentials.
Hence, if the credentials don't exist in the Credential Manager, it appears deleting the package source and closing Visual Studio may be sufficient to cause Visual Studio to forget the saved credentials.
For me this isssue happens if i updated my system password. I fixed this problem by updating the passwords.
Steps:
Go to Control Panel -->User Account -->Credential Manager
In window credentials section update the password of your artifactory with encrypted password.
In Generic Credential section update your generic password which starts with VSCredential_ prefix with encrypted password.
Close and open your visual studio & Rebuild your visual studio project.
You can get encrypted password from you artifactory site(JFrog) user profile section.
You can also try looking in %AppData%\..\Local\NuGet\v3-cache. Some credentials (or configuration pointing to the credentials) are stored in a subfolder that starts with a guid, then a dollar sign, then the feed address. In my case I needed to reset my credentials for the Telerik feed, and the folder was named:
9908746e042bf0f6edf045e1c69a504b09f96883$https_nuget.telerik.com_nuget
I merely deleted the folder, restarted VS, and was asked to enter my credentials.
At least for Visual studio 2017 besides cleaning up credential cache - it does makes sense to wipe up nuget cache folder, as it keeps nuget packages downloaded locally - and then will not try any remote connection while restoring.
Run following two commands from command prompt, after that nuget authentication will be removed:
del /f "%localappdata%\MicrosoftCredentialProvider\SessionTokenCache.dat"
rmdir /s /q "%localappdata%\NuGet"
You can delete your credentials from the Credential Manager or force update the package reference by executing the following command in the Package Manager Console: dotnet nuget update source "your package name" -s "your package source/url" -u "your username" -p "your password/token"
I had to go into the credential manager and remove the machine name, i.e. in Cred Mgr my
User Name was: 10.4.4.4\username
needed to edit back to:
User Name: username

WiX tool packaging, avoid ovewrite file on major upgrade

I have a problem with WiX when I try to generate an MSI (WiX v3.11).
My product is a windows service that must be installed, and during this installation process, I launch a form that collects information for connection to database. This information is stored in a .config file that is installed in the same application folder.
The problem is that if I do an update of the package, I must keep the configuration file, but if I uninstall the application, it should delete the configuration file.
The configuration file can be modified after or during installation.
<MajorUpgrade Schedule="afterInstallInitialize" />
<ComponentGroup Id="ConfigFiles" Directory="INSTALL_SERVICE">
<Component Id="ConfigFile" Guid="11FDDC05-F4D2-4418-82E8-0CB3B3784300" Win64="$(var.Win64)" NeverOverwrite="yes" >
<File Id="F.config" Name="service.config" DiskId="1" Vital="yes" KeyPath="yes" Source="..\Resources\service.config" />
<RemoveFile Id="CleanUpLogFile" On="uninstall" Name="service.config"/>
</Component>
</ComponentGroup>
With this I have managed to delete in the uninstall process and not be modified during the update, but the update process fails.
I have tried and read many solutions on the web but I do not get any of them working.

Opshub conversion troubles to Visual Studio online and converting DOS (8.3) short paths

I am trying to convert our repository from TFS 2012 on-premise to Visual Studio Online.
I am getting errors like this:
OH-SCM-009: Error occurred while sync. TF203013: The path O:\somepath\Jeffkn~1.jpg is in the DOS (8.3) short path format and is not supported. Enter a full path to the item and try again.
I believe we did this during our migration back in the day (method 2):
https://support.microsoft.com/en-us/kb/951195
Which is to add <add key="allow8Dot3Paths" value="true" /> to our TFS temporarily during a migration.
How do I accomplish this today with Visual Studio Online / OpsHub?
Thanks!
The path contains a file name that is in the MS-DOS-compatible short name format (in your case is Jeffkn~1.jpg), you need to change the path to rename the Jeffkn~1.jpg file, for example Jeffkn.jpg.
Additionally, you can't take Method2 in the KB article to enable TFS2012 Application Tier server to allow the MS-DOS-compatible short name format, because there is no problem to have this path in on-premise TFS, you have the problem when migrate item to VSO. So, you need to enable the MS-DOS-compatible short name format for VSO, but I don't think you have permissions to do it.
Could you Please try below steps, it might help
First close the migration utility then add the app setting key "allow8Dot3Paths" to devenv.exe.config ("c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE) or in "c:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE
Under the <configuration> element, locate the <appSettings> element, and then add the following element.
<add key="allow8Dot3Paths" value="true" />
in the devenv.exe.config file.
Now start the migration utility, start the migration and retry the failure, wait for the retry to complete and if you still get the error then please email us the OpsHubTFSService.log file from location "C:\Program Files\OpsHub Visual Studio Online Migration Utility\logs" to support#opshub.com

Using Visual Studio 2012, the manifest signed, but the assembly is not

I am using ClickOnce application deployment, and I just got my code certificate from Verisign. I am using this certificate to sign the manifest.
When I download and install the application, the smartscreen comes up with my name on it (lame, but I think this is what is supposed to happen). When the ClickOnce installer completes, the smartscreen comes up again for the execution of the actual application, here it says 'Unknown Publisher'.
Does ClickOnce not sign the assemblies by default? How do I do this?
Edit: Currently I am letting VS sign my manifest (installer) for the ClickOnce, and I am setting a Post-build event to sign my assembly. But still when I install the application it says 'unknown publisher' when I go to actually run it.
That does not sound right to me. I have used exactly the same workflow for multiple applications, and it works fine. Most likely there is an issue with your postbuild step. Make sure that you sign EXE file inside the OBJ folder (because that's where ClickOnce takes all the files from) - not the BIN one.
Do ClickOnce publishing, go to the OBJ folder, right click on your application.exe file, and select properties. It should have six tabs - the last one being "Digital Signature":
If you don't have it, you don't sign your application properly.
And here is my postbuild step - note that I sign "RELEASE" configuration only:
<Target Name="SignOutput" AfterTargets="CoreCompile" Condition="'$(ConfigurationName)'=='Release'">
<PropertyGroup>
<TimestampServerUrl>http://timestamp.verisign.com/scripts/timestamp.dll</TimestampServerUrl>
<ApplicationDescription>my app</ApplicationDescription>
<SigningCertificateCriteria>/n "my company."</SigningCertificateCriteria>
</PropertyGroup>
<ItemGroup>
<SignableFiles Include="$(ProjectDir)obj\$(ConfigurationName)\$(TargetName)$(TargetExt)" />
</ItemGroup>
<Exec Condition=" '$(ConfigurationName)'=='Release'" Command=""c:\Program Files (x86)\Windows Kits\8.0\bin\x64\signtool.exe" sign $(SigningCertificateCriteria) /d "$(ApplicationDescription)" /t "$(TimestampServerUrl)" "%(SignableFiles.Identity)"" />
</Target>