Issues while trying to assembly the .NET dlls in powershell
Dear team,
I'm trying to use .NET libraries of the google APIs-
I detected the following:
By using the command install-Package -Name Google.Apis.AnalyticsData.v1beta -force -verbose -ProviderName NuGet
the installation is aborted due to a loop in the dependencies. here the full verbose output:
PS C:\WINDOWS\system32> install-Package -Name Google.Apis.AnalyticsData.v1beta -force -verbose -ProviderName NuGet VERBOSE: Using the provider 'NuGet' for searching packages. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis.AnalyticsData.v1beta'' for ''. VERBOSE: Total package yield:'1' for the specified package 'Google.Apis.AnalyticsData.v1beta'. VERBOSE: Performing the operation "Install Package" on target "Package 'Google.Apis.AnalyticsData.v1beta' version '1.61.0.3141' from 'nuget.org'.". VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis.AnalyticsData.v1beta'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis.Core'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.CSharp'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='NETStandard.Library'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.Platforms'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime.InteropServices.RuntimeInformation'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.Targets'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.IO'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.Platforms'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.Targets'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Text.Encoding'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Threading.Tasks'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection.Primitives'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection.Extensions'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Resources.ResourceManager'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Threading'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.native.System'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime.InteropServices'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime.Handles'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Win32.Primitives'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.AppContext'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Collections'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Console'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.Targets'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization.Calendars'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.IO.Compression'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.native.System.IO.Compression'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Buffers'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Diagnostics.Debug'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Diagnostics.Tracing'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime.Extensions'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.IO.Compression.ZipFile'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.IO.FileSystem'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.IO.FileSystem.Primitives'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Net.Http'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Security.Cryptography.X509Certificates'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Security.Cryptography.Algorithms'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Security.Cryptography.Primitives'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Security.Cryptography.Encoding'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.fedora.27-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.fedora.28-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.opensuse.42.3-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.ubuntu.18.04-x64.runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Collections.Concurrent'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Linq'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.native.System.Security.Cryptography.Apple'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='runtime.native.System.Security.Cryptography.OpenSsl'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime.Numerics'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Security.Cryptography.Cng'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Security.Cryptography.Algorithms'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.Platforms'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Formats.Asn1'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Buffers'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Memory'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Runtime.CompilerServices.Unsafe'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='System.Numerics.Vectors'' for ''. VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='NETStandard.Library'' for ''. install-Package : Dependency loop detected for package 'Google.Apis.AnalyticsData.v1beta'. At line:1 char:1
- install-Package -Name Google.Apis.AnalyticsData.v1beta -force -verbos ...
-
+ CategoryInfo : Deadlock detected: (Google.Apis.AnalyticsData.v1beta:String) [Install-Package], Exception + FullyQualifiedErrorId : DependencyLoopDetected,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Second issue, not sure if related, but can be the same root cause. I can of course skip dependencies and download the package, and use the assembly (*.dll) directly but then there is an issue with the dependencies. After working out each error, I manage to get to this list and this order: add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Google.Api.CommonProtos.2.10.0\lib\net461\Google.Api.CommonProtos.dll" add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Google.Apis.1.61.0\lib\net45\Google.Apis.dll" add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Google.Apis.Core.1.61.0\lib\net45\Google.Apis.Core.dll" add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Google.Apis.Auth.1.61.0\lib\net45\Google.Apis.Auth.dll" add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Grpc.Core.Api.2.55.0\lib\net462\Grpc.Core.Api.dll" add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Google.Api.Gax.Grpc.4.3.0\lib\net462\Google.Api.Gax.Grpc.dll" add-type -path "C:\Program Files\PackageManagement\nuget\Packages\Google.Api.Gax.4.3.0\lib\net462\Google.Api.Gax.dll" add-type -Path "C:\Program Files\PackageManagement\NuGet\Packages\Google.Analytics.Data.V1Beta.2.0.0-beta03\lib\netstandard2.1\Google.Analytics.Data.V1Beta.dll"
but then, is asking again "Could not load file or assembly 'Google.Protobuf" when is clear that Google.Protobuf is already loaded in the assembly.
Any idea on what I could bedoing wrong? or, perhaps for a reason, the .NET library is not fully fucntioning for the beta version of the API assemblies.
Thanks!
I'll try to reproduce and report back.
I see the same error as you when using PowerShell and Install-Package. But, I just created the following console app that runs as expected (I get an Unauthorized error as I didn't inlcude authentication code), which basically proves that there's nothing intrinsically wrong with the Google.Apis.AnalyticsData.v1beta library or its dependencies.
Doing a quick internet search, there seems to be plenty of questions and blog posts about Install-Package and dependency loops, and skimming over them most seem to have been fixed by passing specific parameters to Install-Package. I'm not familiar with Install-Package so I'm afraid I cannot help there.
As for the second issue you mention, it's not clear to me what steps you are following to include the dependency manually. But again, given that my project below works, whatever problems you are seeing are most likely because of the steps you are following and not because of the library itself.
@jskeet in case I'm missing something.
My project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Google.Apis.AnalyticsData.v1beta_PowerShell_Issue2504</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Apis.AnalyticsData.v1beta" Version="1.61.0.3141" />
</ItemGroup>
</Project>
My Console App
using Google.Apis.AnalyticsData.v1beta;
var analyticsData = new AnalyticsDataService();
var request = analyticsData.Properties.GetMetadata("properties/1234/metadata");
var response = request.Execute();
Console.WriteLine(response);
It's unclear to me whether PowerShell is the language your project is in, or just that you're using Install-Package from PowerShell. A minimal but complete example would really help here - and please err on the side of completeness in terms of all the files involved, as no-one on the team works with PowerShell regularly.
Like Amanda, I strongly suspect that the issue is with the tooling rather than the library itself.
Good morning team,
Yes, the goal I want to achieve is to build an automation with powershell that integrates with other automation we are working on. Therefore, if we achieve this in powershell would be ideal. As you know, Powershell is build using the whole MS foundation, therefore, in theory, integration with the .NET libraries should not be a problem.
So, if you want to use the types, classes, and all of that stuff, you need to install the packages in your environment. First you need to install the NuGet package source as such, and once you are there, you can install the packages from NuGet.
Then, by looking at this page: https://developers.google.com/api-client-library/dotnet/apis/analytics/v3, it has a link to install the Install the NuGet package: Google.Apis.Analytics.v3 https://www.nuget.org/packages/Google.Apis.Analytics.v3
To install this in powershell, you run the command
install-Package -Name Google.Apis.Analytics.v3 -force -verbose -ProviderName NuGet <---I added the -verbose flag so you can see what is doing.
The the process starts to analyze dependencies: First view lines are ok:
VERBOSE: Performing the operation "Install Package" on target "Package 'Google.Apis.Analytics.v3' version '1.61.0.1679' from 'nuget.org'.". VERBOSE: Searching repository ' https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis.Analytics.v3'' for ''. VERBOSE: Searching repository ' https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis'' for ''. VERBOSE: Searching repository ' https://www.nuget.org/api/v2/FindPackagesById()?id='Google.Apis.Core'' for ''. VERBOSE: Searching repository ' https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json'' for ''.
but from here starts to search for more and more packages recursively until it get a loop with 'NETStandard.Library''.
There is a way to avoid checking dependencies with the flag -skipDependencies. I did it for the packages of Google.Apis, Google.Apis.Core and Newtonsoft.Json. So they are available on my system.
I also installed this one:
install-Package -Name Google.Analytics.Data.V1Beta -force -verbose -ProviderName NuGet -skipDependencies -requiredVersion 2.0.0-beta03
I want to run an example described here: https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries#python_1
So, translating this to powershell, would be
using assembly "C:\Program Files\PackageManagement\NuGet\Packages\Google.Analytics.Data.V1Beta.2.0.0-beta03\lib\net462\Google.Analytics.Data.V1Beta.dll" $client = [BetaAnalyticsDataClient]::Create()
Then an error is thrown as class BetaAnalyticsDataClient is not found.
So, to check if the assembly is being loaded as it should, you can use this command after the 'using assembly estatement before
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted | Out-GridView
and I see that google assembly is loaded:
Google.Analytics.Data.V1Beta, Version=2.0.0.0, Culture=neutral, PublicKeyToken=185c282632e132a0
Now, let's list all types loaded in the assembly:
([appdomain]::currentdomain.GetAssemblies() | Where-Object Location -Match 'google').gettypes()
and this command thorws an error:
PS C:\WINDOWS\system32> ([appdomain]::currentdomain.GetAssemblies() | Where-Object Location -Match 'google').gettypes() Exception calling "GetTypes" with "0" argument(s): "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
And to see what the actual error is, let's expand the LoaderExceptions using a try catch statement. The full code now looks like this:
using assembly "C:\Program Files\PackageManagement\NuGet\Packages\Google.Analytics.Data.V1Beta.2.0.0-beta03\lib\net462\Google.Analytics.Data.V1Beta.dll"
try {
([appdomain]::currentdomain.GetAssemblies() | Where-Object Location -Match 'google').gettypes()
} catch [System.Reflection.ReflectionTypeLoadException] {
Write-Host $_.Exception.Message -ForegroundColor Yellow
Write-Host $_.Exception.StackTrace -ForegroundColor DarkYellow
if($null -ne $_.Exception.LoaderExceptions) {
foreach($loaderEx in $_.Exception.LoaderExceptions) {
Write-Host "LoaderException: $loaderEx" -ForegroundColor Cyan
}
}
throw 'Error occured while loading PoShLog libraries!'
}
The output I get out of this code reveals a dependency in the first few lines:
LoaderException: System.IO.FileNotFoundException: Could not load file or assembly 'Google.Protobuf, Version=3.21.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604' or one of its dependencies. The system cannot find the file specified. File name: 'Google.Protobuf, Version=3.21.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'
As you can see, Google.Protobuf somwhow is referenced within Google.Analytics.Data.V1Beta, so seems to me like a reference not documented in the NuGet repository.
What I did then is to downloead the Google.Protobuf from Nuget. then same error, but now pointing to other assembly, and so on and so on, until it returned again to an error on Google.Protobuf,.. and never manage to get out of these loop.
I see that perhaps powershell is not the main paltform you are aiming at - but as motivation - powershell assembles are really powerfull. If you sort this out, a hughe integrator community will raise a glass in your name.
Hope this is more clearer!
On Mon, Aug 21, 2023 at 10:17 AM Jon Skeet @.***> wrote:
It's unclear to me whether PowerShell is the language your project is in, or just that you're using Install-Package from PowerShell. A minimal but complete example would really help here - and please err on the side of completeness in terms of all the files involved, as no-one on the team works with PowerShell regularly.
Like Amanda, I strongly suspect that the issue is with the tooling rather than the library itself.
— Reply to this email directly, view it on GitHub https://github.com/googleapis/google-api-dotnet-client/issues/2504#issuecomment-1685868286, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXZEG3KRMPQYL5QNFQ5UHTXWMKQPANCNFSM6AAAAAA3V77ERM . You are receiving this because you authored the thread.Message ID: @.***>
As an aside, it would be useful to stick with one library - your comments above talk about Google.Apis.Analytics.v3, Google.Apis.AnalyticsData.v1beta and Google.Analytics.Data.V1Beta which are very different libraries with very different dependencies. I don't want to get to the bottom of installing one, only to be told that it's the other one you actually want to install.
Note that the dependency from Google.Analytics.Data.V1Beta to Google.Protobuf is effectively documented in NuGet, but it's indirect: Google.Analytics.Data.V1Beta depends on Google.Api.Gax.Grpc, which depends on Google.Api.CommonProtos, which depends on Google.Protobuf.
"To install this in powershell, you run the command [....]"
That's assuming you're already in the context of the project, isn't it? What does that project look like?
Again, a complete repro would be really helpful - assume I have appropriate tooling required, but nothing else. Basically, start from "mkdir Issue2504" or the equivalent... Tell us about every file you create manually, and every command you run.
Here's an equivalent example for C# which works (commands run from bash):
$ mkdir Issue2504CSharp
$ cd Issue2504CSharp
$ dotnet new console
$ dotnet add package Google.Analytics.Data.V1Beta --prerelease
$ # Edit Program.cs as described below
$ dotnet build
$ dotnet run
Program.cs should be edited to look like this:
using Google.Analytics.Data.V1Beta;
var client = BetaAnalyticsDataClient.Create();
So, what's the equivalent list of steps for PowerShell?
(I'd really hope you don't need to explicitly load a particular DLL in PowerShell... that feels like a bit of a recipe for disaster with any significant set of dependencies. The modern .NET ecosystem really isn't designed to work that way.)
Hej Jon,
The steps are pretty similar. What you achieve with the "dotnet add package,...:" in powershell means that you install the .NET libraries where Powerhsell can find them.
Open powershell ISE with elevated rights and run the following commands (Powershell ISE comes with the base Windows 11 - menu start, type 'ISE' you will see it):
First you need to setup powershell to be able to consume NuGet
Install-PackageProvider -Name NuGet -Force
then you need to install the NuGet powershell module:
Install-Module -Name NuGet -Force
Once here, in theory, you install the binaries:
Install-Package -Name Google.Analytics.Data.V1Beta -force -verbose -ProviderName NuGet -RequiredVersion 2.0.0-beta03
the directive -Verbose is in purpose for you to see all details ... then you see that a loop is reached while checking dependencies, and the installation of this package does not fly.
Assuming that this installation would work, the actual powershell code would be something like (you can save this code as "PageViews.ps1" and run it.
using namespace Google.Analytics.Data.V1Beta $client = [BetaAnalyticsDataClient]::Create()
I'm with you - the idea here is not to deal with every single DLL becuase becomes a monster agreed.
hope this helps! Glad to answer more questions.
Kind regards,
Kind regards
On Mon, Aug 21, 2023 at 11:34 AM Jon Skeet @.***> wrote:
As an aside, it would be useful to stick with one library - your comments above talk about both Google.Apis.Analytics.v3 and Google.Analytics.Data.V1Beta which are very different libraries with very different dependencies. I don't want to get to the bottom of installing one, only to be told that it's the other one you actually want to install.
Note that the dependency from Google.Analytics.Data.V1Beta to Google.Protobuf is effectively documented in NuGet, but it's indirect: Google.Analytics.Data.V1Beta depends on Google.Api.Gax.Grpc, which depends on Google.Api.CommonProtos, which depends on Google.Protobuf.
"To install this in powershell, you run the command [....]"
That's assuming you're already in the context of the project, isn't it? What does that project look like?
Again, a complete repro would be really helpful - assume I have appropriate tooling required, but nothing else. Basically, start from "mkdir Issue2504" or the equivalent... Tell us about every file you create manually, and every command you run.
Here's an equivalent example for C# which works (commands run from bash):
$ mkdir Issue2504CSharp $ cd Issue2504CSharp $ dotnet new console $ dotnet add package Google.Analytics.Data.V1Beta --prerelease $ # Edit Program.cs as described below $ dotnet build $ dotnet run
Program.cs should be edited to look like this:
using Google.Analytics.Data.V1Beta; var client = BetaAnalyticsDataClient.Create();
So, what's the equivalent list of steps for PowerShell?
— Reply to this email directly, view it on GitHub https://github.com/googleapis/google-api-dotnet-client/issues/2504#issuecomment-1685985169, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXZEG63SQ7KUYASIDALXCTXWMTTPANCNFSM6AAAAAA3V77ERM . You are receiving this because you authored the thread.Message ID: @.***>
Hmm... when I try that, it doesn't even manage to get through to NuGet properly:
PS C:\...\Issue2504b> Install-Package -Name Google.Analytics.Data.V1Beta -force -verbose -ProviderName NuGet -RequiredVersion 2.0.0-beta03
VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Retry downloading 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='FoooBarr'' for '2' more times
VERBOSE: Retry downloading 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='FoooBarr'' for '1' more times
VERBOSE: Retry downloading 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='FoooBarr'' for '0' more times
VERBOSE: Total package yield:'0' for the specified package 'Google.Analytics.Data.V1Beta'.
Install-Package : No match was found for the specified search criteria and package name 'Google.Analytics.Data.V1Beta'. Try Get-PackageSource to see all available registered package sources.
I get the same output - including the FoooBarr ID - whatever package I try to install.
I'll try on another machine...
Same result on another machine.
It looks like your original issue is a known problem with the OneGet provider which is no longer even being maintained.
Basically, this really looks like it's a case of "the PowerShell ecosystem can't consume NuGet packages properly" which isn't something we can address.
I'll close this issue now as it doesn't look like something we can fix.
Thanks a lot Jon!
I saw you opened a case with the people of NuGet - Hope they pick it!
Kind regards.
On Wed, Aug 23, 2023 at 4:54 PM Jon Skeet @.***> wrote:
I'll close this issue now as it doesn't look like something we can fix.
— Reply to this email directly, view it on GitHub https://github.com/googleapis/google-api-dotnet-client/issues/2504#issuecomment-1690114678, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXZEG7A4Q5ME6MFAR2GDKDXWYKS5ANCNFSM6AAAAAA3V77ERM . You are receiving this because you authored the thread.Message ID: @.***>