NuGet Push Error 500 (without Proxy), Error 503 (with Proxy) - azure-devops

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!

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.

dotnet nuget push with user credentials

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.

How do you enable logging for CrmServiceClient in the Xrm Tooling toolkit?

I'm having issues trying to log in to a CRM Online organization through the use of the latest version of the Xrm Tooling nuget package using the connection string constructor from a custom powershell cmdlet.
I'm receiving a rather unhelpful "Unable to Login to Dynamics CRM" error message and am attempting to enable tracing to troubleshoot but have not been able to enable it by modifying the .dll.config file like the below (taken from an XrmToolbox issue on GitHub):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
switchName="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console" type="System.Diagnostics.DefaultTraceListener" />
<remove name="Default" />
<add name ="fileListener" />
</listeners>
</source>
<source name="Microsoft.Xrm.Tooling.CrmConnectControl"
switchName="Microsoft.Xrm.Tooling.CrmConnectControl"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console" type="System.Diagnostics.DefaultTraceListener" />
<remove name="Default" />
<add name ="fileListener" />
</listeners>
</source>
</sources>
<switches>
<!--
Possible values for switches: Off, Error, Warning, Info, Verbose
Verbose: includes Error, Warning, Info, Trace levels
Info: includes Error, Warning, Info levels
Warning: includes Error, Warning levels
Error: includes Error level
-->
<add name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient" value="Verbose" />
<add name="Microsoft.Xrm.Tooling.CrmConnectControl" value="Verbose" />
<add name="Microsoft.Xrm.Tooling.WebResourceUtility" value="Verbose" />
</switches>
<sharedListeners>
<add name="fileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="XRMToolingLogs.log" />
<!--<add name="eventLogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="XRMTooling" />-->
</sharedListeners>
</system.diagnostics>
</configuration>
I was able to work around this by configuring the listener programmatically through:
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.TraceLevel = System.Diagnostics.SourceLevels.All;
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.AddTraceListener(new TextWriterTraceListener("log.txt"));
Which pointed me to the actual error which was that the CrmServiceClient was expecting a URL with the organization unique name instead of the URL name.

Send only endpoints can't publish messages NserviceBus 5.2

I am using SendOnlyBus with NserviceBus 5.2
and my set-up code is like
busConfiguration.UsePersistence<NHibernatePersistence,StorageType.Subscriptions>();
busConfiguration.AssembliesToScan(AssembliesToScan);
busConfiguration.UseTransport<MsmqTransport>();
busConfiguration.PurgeOnStartup(false);
busConfiguration.UseSerialization<XmlSerializer>();
return Bus.CreateSendOnly(busConfiguration);
and web.config
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MsmqTransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core" />
<MsmqTransportConfig InputQueue="XXX" ErrorQueue="XXX" NumberOfWorkerThreads="X" MaxRetries="X" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="X" Endpoint="X" />
</MessageEndpointMappings>
</UnicastBusConfig>
<add name="NServiceBus/Persistence" connectionString="Data Source=XXX;database=XXX;User ID=XX;Password=XXx;" />
<add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
this leads to error while publishing message.
Cannot publish on this endpoint - no subscription storage has been
configured."
If i use Memory Persistence, it works fine but not with Hibernate
DB-Subscription, Not able to find out what's missing or wrong.
Appreciate any help ?.
Thanks
Explanation
NServiceBus is not configuring subscription persistence because you have asked for a send only endpoint.
Send only endpoints do not have an input queue, which means they have no way to receive and store subscriptions. Trying to Publish makes no sense if you have no subscribers.
Either
keep the send only bus, but switch from using Bus.Publish() to Bus.Send()
or
use a complete bus by calling return Bus.Create(busConfiguration) instead of return Bus.CreateSendOnly(busConfiguration)
Code sample
The only code needed to publish an event with NHibernate as subscription persistence on NServiceBus 5.2.0 and NServiceBus.NHibernate 6.1.2 is the following:
Program.cs
using System;
using NServiceBus;
using NServiceBus.Features;
using NServiceBus.Persistence;
class Program
{
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.DisableFeature<TimeoutManager>();
busConfiguration.UsePersistence<NHibernatePersistence, StorageType.Subscriptions>();
using (IStartableBus bus = Bus.Create(busConfiguration))
{
bus.Start();
bus.Publish(new SomeEvent());
Console.WriteLine("Published an event");
Console.ReadLine();
}
}
class SomeEvent : IEvent {}
}
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NServiceBus/Persistence" connectionString="Data Source=.;database=database;User ID=user;Password=password;"/>
</connectionStrings>
<appSettings>
<add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2012Dialect" />
</appSettings>
</configuration>