dotnet nuget push with user credentials - nuget

I am trying to push package from Linux via dotnet-cli.
I have my own nuget server - via package https://www.nuget.org/packages/NuGet.Server/
Using following command:
dotnet nuget push mypackage.nupkg
I have XML config with package source:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<config>
<add key="DefaultPushSource" value="https://mynuget.azurewebsites.net/api/v2/package" />
</config>
<packageSources>
<add key="MyNuget" value="https://mynuget.azurewebsites.net/api/v2/package" />
</packageSources>
<packageSourceCredentials>
<MyNuget>
<add key="Username" value="user" />
<add key="ClearTextPassword" value="pass" />
</MyNuget>
</packageSourceCredentials>
<apikeys>
<add key="https://mynuget.azurewebsites.net/" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAV4A39UQG0kyF2wMV56X9wQAAAAACAAAAAAAQZgAAAAEAACAAAAABPigYqsJ8B9Vcs2e6SXGUKbqctjmrNyoUQz/6H7FSWwAAAAAOgAAAAAIAACAAAAAhm/tVYS41jbvn9NIL6IPHFSFDpBDL/fbBXzdTBSRvWRAAAACY41RYMpAJoSeSdq5paZCvQAAAADZRmyl+f4XYYnPpi1Ia9Kf0TsM6ddNXUL2sJIWXtQ6zNOliZ1IGlpU62c83v93siZp7GCRjj9fIoG6ixbK2Rxg=" />
</apikeys>
</configuration>
Error message which I am getting is:
warn : No API Key was provided and no API Key could be found for 'https://mynuget.azurewebsites.net/api/v2/package'.
To save an API Key for a source use the 'setApiKey' command.
info : Pushing mypackage.nupkg to 'https://mynuget.azurewebsites.net/api/v2/package'...
info : PUT https://mynuget.azurewebsites.net/api/v2/package/
info : Forbidden https://mynuget.azurewebsites.net/api/v2/package/ 3898ms
It seems that nuget.config is completely ignored by dotnet-cli?
I also cannot pass --config-file parameter - getting error error: Unrecognized option '--config-file' but it should be possible as per documentation:
https://github.com/dotnet/docs/blob/master/docs/core/tools/dotnet-nuget-push.md

I managed to get it to work by just putting my nuget.config in the same folder as the .nupkg file and running dotnet nuget push from that folder.

It seems the issue is described here:
https://github.com/NuGet/Home/issues/4879 and it's still in the Open status.
It also looks like someone already created a fix: https://github.com/automotiveMastermind/condo/issues/50.

Related

aspnet_regiis saying success but connectionString section unchanged

So I have a web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<connectionStrings>
<clear />
<add name="AS400" providerName="System.Data.ProviderName" connectionString="DataSource=REDACTED; UserID=REDACTED; Password=REDACTED; InitialCatalog=REDACTED; DataCompression=True; CheckConnectionOnOpen=True; CharBitDataAsString=True; Naming = System" />
</connectionStrings>
...
And I'm trying to figure out how to encrypt the connectionStrings section, following this documentation.
I navigated to the location of the published web app and ran the following command as an admin: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pe "connectionStrings" -app / -prov "RsaProtectedConfigurationProvider"
The command output the following:
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Encrypting configuration section...
Succeeded!
...But it didn't seem to do anything! The web.config is unchanged.
I'm probably missing something obvious here but I've never used aspnet_regiis before so I have no idea how to proceed.
I got it. Running it with an app of \ in the correct location isn't good enough. (Likewise, for some reason, navigating to just C:\Windows\Microsoft.NET\Framework64\v4.0.30319 then running aspnet_regiis doesn't work). Need to fully-qualify both paths:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pef "connectionStrings" "C:\Atlassian\bamboo-home\xml-data\build-dir\4587526-3997713"

Azure Pipelines NuGet.config packages failed to restore

I am trying to build an Xamarin app with a custom Nuget Config but the build fails when I get to the restore command.
I get the following error:
The nuget command failed with exit code(1) and error(Failed to retrieve information about 'BCrypt.Net-PCL' from remote source 'http://nuget.uxdivers.com/grial/FindPackagesById()?id='BCrypt.Net-PCL'&semVerLevel=2.0.0'. The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
The package "BCrypt.Net-PCL" is a NuGet package but the restore command is looking for it in the "uxdrivers" source.
If I run without a custom NuGet.config the restore can find all NuGet packages but obviously it fails to find the none NuGet sources thus the build fails as well.
I've tried shifting the order of the package sources, the credentials and tried a different vmImage but I always end up with this error.
See below my YAML:
- task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'NuGet.config'
See below my NuGet.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<clear />
<packageSources>
<add key="Grial" value="http://nuget.uxdivers.com/grial"/>
<add key="Syncfusion_Xamarin" value="https://nuget.syncfusion.com/nuget_xamarin/nuget/getsyncfusionpackages/xamarin"/>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<Syncfusion_Xamarin>
<add key="Username" value="*MyUsername*" />
<add key="Password" value="*MyPassword*" />
</Syncfusion_Xamarin>
<Grial>
<add key="Username" value="*MyUsername*" />
<add key="Password" value="*MyPassword*" />
</Grial>
</packageSourceCredentials>
Azure Pipelines NuGet.config packages failed to restore
It seems the way you configured in the Nuget.Config file have a syntax error.
If there is encrypted password it won't work on a different machine as it's encoded with a key from stored on you dev machine. You could replace it with clear text password, like:
<add key="Username" value="%USER_VARIABLE%" />
<add key="Password" value="%PASSWORD_VARIABLE%" />
Or use the cleartextpassword:
<add key="Username" value="user" />
<add key="ClearTextPassword" value="xxxxxx" />
Check the document nuget.config reference for some more details.
Hope this helps.

NuGet Push Error 500 (without Proxy), Error 503 (with Proxy)

I try to Push a nupkg to a Artifacts in a Azure DevOps Server.
The network is behind a proxy so my C:\Users\user\AppData\Roaming\NuGet\NuGet.Config looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="FrameworkA" value="http://xfc-l-s6fc5086:8070/Samples/_packaging/FrameworkA/nuget/v3/index.json" />
</packageSources>
<config>
<add key="http_proxy" value="http://my-proxy:8000" />
<add key="http_proxy.user" value="domain\user" />
<add key="http_proxy.password" value="*** windows security key ***" />
</config>
</configuration>
From my feed (Azure DevOps) page I get the following information:
so if I execute:
nuget.exe push -Source "FrameworkA" -ApiKey AzureDevOps .\FrameworkA.1.0.0.nupkg
I get:
The response status code does not indicate success: 503 (Service Unavailable).
I remove the proxy information from my nuget.config and I get:
The response status code is unsuccessful: 500 (Internal Server Error - Error retrieving data from the upstream packet source https://api.nuget.org/v3/index.json): Error sending the request. (DevOps activity ID: 69FB4414-ED0B-4367-B121-B0DC9B366367)).
And I also get this meaasge when I remove the entry:
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
Whats going wrong here? Has anybody experience with Azure DevOps Server behind a proxy? (everything else with azure devops server works fine, REST API, Custom Extension, Build- and release tasks and so on)
Version: 17.143.28912.1 (AzureDevOps2019.0.1)
I got the same and solved it because of a typo. If I add the DevOps as Proxy it works.
<add key="http_proxy" value="http://devops.yourdomain:8080" />
That worked im my case. IDK why!

How to implement parallel execution using Specrun for NUnit

I have installed the following NuGets : Specflow.Nunit,specflow ,Specrun.Nunit along with NUnit 2.6.3.
I am trying to execute runtests.cmd(automatically generated by specrun.nunit) but I am getting the following error :
TechTalk.SpecRun.Framework.SpecRunException: At least one test thread aborted. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Void TechTalk.SpecRun.SpecRunner.Initialize()'.
My default.srprofile contains :
<?xml version="1.0" encoding="utf-8"?>
<TestProfile xmlns="http://www.specrun.com/schemas/2011/09/TestProfile">
<Settings projectName="<PROJECTNAME>" projectId="{------}" />
<Execution stopAfterFailures="3" testThreadCount="2" testSchedulingMode="Sequential" />
<!-- For collecting by a SpecRun server update and enable the following element. For using the
collected statistics, set testSchedulingMode="Adaptive" attribute on the <Execution> element.
<Server serverUrl="http://specrunserver:6365" publishResults="true" />
-->
<TestAssemblyPaths>
<TestAssemblyPath>projectname.dll</TestAssemblyPath>
</TestAssemblyPaths>
<DeploymentTransformation>
<Steps>`enter code here`
<!-- sample config transform to change the connection string-->
<!--<ConfigFileTransformation configFile="App.config">
<Transformation>
<![CDATA[<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDatabase" connectionString="Data Source=.;Initial Catalog=MyDatabaseForTesting;Integrated Security=True"
xdt:Locator="Match(name)" xdt:Transform="SetAttributes(connectionString)" />
</connectionStrings>
</configuration>
]]>
</Transformation>
</ConfigFileTransformation>-->
</Steps>
</DeploymentTransformation>
</TestProfile>
Also on the VS Output window I am getting this error :
Could not load file or assembly 'TechTalk.SpecRun, Version=1.3.0.76, Culture=neutral, PublicKeyToken=d0fc5cc18b3b389b' or one of its dependencies. The system cannot find the file specified.
Can someone please help me with this ?
You would to change this strings:
<RelocateConfigurationFile target="CustomConfig.{TestThreadId}.config" />
<ConfigFileTransformation configFile="App.config">
Full answer:
https://github.com/techtalk/SpecFlow/issues/954

fontawsome-webfont.woff not found error in deployed Orchard CMS website

I use Orchard CMS 1.10.1. In the layout.cshtml file of current theme, I added these:
Style.Require("bootstrap");
Style.Require("fontawesome");
and the web.config file of Orchard.Web contains these:
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
</staticContent>
In my machine there was no problem but when I deployed this on server I get these errors in browser console:
Get http://x.com/Themes/y/fonts/fontawesome-webfont.woff2?v=4.3.0
GET http://x.com/Themes/y/fonts/fontawesome-webfont.woff?v=4.3.0
GET http://x.com/Themes/y/fonts/fontawesome-webfont.ttf?v=4.3.0 404 (Not Found)
What might cause this problem?
You need a <clear/> as first element inside static handlers before first <remove..../> and add a ttf handler as well