Zeugwerk / Twinpack

Twinpack is a package manager for TwinCAT libraries with integration into the TwinCAT IDE. It enables the TwinCAT community to share their libraries and simplifies the continous integration of third-party components into TwinCAT projects.
https://twinpack.dev
GNU General Public License v3.0
51 stars 3 forks source link

Unable to LogIn into Azure Artifact Server #135

Closed ThatsFokus closed 1 month ago

ThatsFokus commented 1 month ago

When adding a NuGet Source from an Azure Repository it seems to be impossible to Log In, Security Dialog just closes and open again wether the credentials are correct or not. Also besides killing the Shell with Taskmanager it is impossible to stop the dialog from opening again

iadonkey commented 1 month ago

Can you post the detailed log messages from %LOCALAPPDATA%\Zeugwerk\logs\Twinpack

The credentials are verified by checking the feed for packages, are there any in the feed? https://github.com/Zeugwerk/Twinpack/blob/264bb296cfad91ee64cffee77453d78483b5adbf/TwinpackShared/Protocol/Nuget/NugetServer.cs#L479

edit: fixed log location, fyi @ThatsFokus

iadonkey commented 1 month ago

Also besides killing the Shell with Taskmanager it is impossible to stop the dialog from opening again

will be fixed, https://github.com/Zeugwerk/Twinpack/issues/136

ThatsFokus commented 1 month ago

Twinpack.debug.log Countdown.nuspec.txt

@iadonkey Here is the Log and and a nuspec for one of the uploaded packages

iadonkey commented 1 month ago

This is a parsing error coming from NuGet.Packaging.Core, are you sure that the URL for your feed is correct and returning a valid xml for NuGet? Is there something reasonable visible in the browser when you navigate to the feed's URL?

Just tried it before and our nuget feed works just fine, it's not in azure but in a docker container though

ThatsFokus commented 1 month ago

checking the source with nugetCLI it has the package listed as avaiable, the same happenes in the web interface. Could there be other reasons why it has said Parsing error?

iadonkey commented 1 month ago

could you post the xml it returns if you go to the feed? maybe try to disable authentication on the feed for testing? is there an API key, which is need to access the feed?

ThatsFokus commented 1 month ago

Hey, managed to connect the feed after some more trouble Shooting including manually editing the index.json.

Sadly I am currently unable to see the Package in the Twincat Extensions feed.

could you post the xml it returns if you go to the feed? maybe try to disable authentication on the feed for testing? is there an API key, which is need to access the feed?

how should I go about reading said xml?

2024-07-30 12:20:06.8235|INFO|Twinpack.Dialogs.CatalogWindow|Reloading catalog 2024-07-30 12:20:06.8557|INFO|Twinpack.Dialogs.CatalogWindow|Package TwinCAT.XAE.PLC.Lib.Tc2_Standard (version: , distributor: Beckhoff Automation) located on https://public.tcpkg.beckhoff-cloud.com/api/v1/feeds/stable 2024-07-30 12:20:06.8557|INFO|Twinpack.Dialogs.CatalogWindow|Package TwinCAT.XAE.PLC.Lib.Tc2_System (version: , distributor: Beckhoff Automation) located on https://public.tcpkg.beckhoff-cloud.com/api/v1/feeds/stable 2024-07-30 12:20:06.8557|INFO|Twinpack.Dialogs.CatalogWindow|Package TwinCAT.XAE.PLC.Lib.Tc2_Utilities (version: , distributor: Beckhoff Automation) located on https://public.tcpkg.beckhoff-cloud.com/api/v1/feeds/stable 2024-07-30 12:20:06.8687|INFO|Twinpack.Dialogs.CatalogWindow|Package TwinCAT.XAE.PLC.Lib.Tc3_EventLogger (version: 3.3.8.0, distributor: Beckhoff Automation) located on https://public.tcpkg.beckhoff-cloud.com/api/v1/feeds/stable 2024-07-30 12:20:06.8687|INFO|Twinpack.Dialogs.CatalogWindow|Package TwinCAT.XAE.PLC.Lib.Tc3_Module (version: , distributor: Beckhoff Automation) located on https://public.tcpkg.beckhoff-cloud.com/api/v1/feeds/stable 2024-07-30 12:20:07.0687|TRACE|Twinpack.Dialogs.CatalogWindow|System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at Twinpack.Dialogs.CatalogWindow.<LoadNextCatalogPageAsync>d__173.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Twinpack.Dialogs.CatalogWindow.<LoadAvailablePackagesAsync>d__172.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Twinpack.Dialogs.CatalogWindow.<Reload>d__183.MoveNext() 2024-07-30 12:20:07.0717|ERROR|Twinpack.Dialogs.CatalogWindow|The operation was canceled.

Edit: The changed Exception in the log

iadonkey commented 1 month ago

If login now works then there is no need for doing anyhting with the xml. The exception you posted indicate that the operation for getting the packages was canceled, usually this happens when you press the "X" button while the query is running. Is there some different exception if you just let it run? is it timing out or anything like that?

iadonkey commented 1 month ago

what did you change in the index.json bzw? there shouldn't be any need to changes this, we are using the official nuget package to connect to nuget servers, as long as version 3 is supported by the server everything should be fine. We don't have an azure instance to test, but it works with nexus and https://github.com/idoop/docker-nuget-server

ThatsFokus commented 1 month ago

image image image

If login now works then there is no need for doing anyhting with the xml. The exception you posted indicate that the operation for getting the packages was canceled, usually this happens when you press the "X" button while the query is running. Is there some different exception if you just let it run? is it timing out or anything like that?

Seemingly it just doesn't find anything, there isn't any exception but as shown in the first screenshot the package is published on the feed.

Should you be able to tell any problem with the nuget itself I would be happy about an idea

iadonkey commented 1 month ago

if there is "Library" with a capital "L" in the tags, we had to include some heuristics for Beckhoff. Could you try to add an additional Tag after Library with the name of the library, so it looks like "Small CountDown Library CountDown"? We accidently use the heuristics for the normal nuget servers as well, so this might be the problem

ThatsFokus commented 1 month ago

Countdown.nuspec.txt

if there is "Library" with a capital "L" in the tags, we had to include some heuristics for Beckhoff. Could you try to add an additional Tag after Library with the name of the library, so it looks like "Small CountDown Library CountDown"? We accidently use the heuristics for the normal nuget servers as well, so this might be the problem

Hey sorry for coming back to you this late. As shared somewhere above here is my nuspec once again.

I didn't really follow what I would have to change so it conforms with Beckhoffs heuristics.

iadonkey commented 1 month ago

Not sure where the „Small“ and „Library“ tag in your screenshot are coming from with this nuspec

anyway, we‘ll write some documentation how to publish a nuget package which is useable with Twinpack. Just a bit busy at the moment

iadonkey commented 1 month ago

btw. this is what beckhoff nuspecs look like

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>TwinCAT.XAE.PLC.Lib.Tc2_Math</id>
    <version>3.4.4</version>
    <title>Beckhoff TwinCAT XAE PLC Library Tc2_Math</title>
    <authors>Beckhoff Automation</authors>
    <owners>Beckhoff Automation</owners>
    <projectUrl>https://www.beckhoff.com/en-us/products/automation/twincat/</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Contains Beckhoff TwinCAT XAE PLC Library Tc2_Math version 3.4.4.0</description>
    <summary>TwinCAT-XAE-PLC-Lib-Tc2_Math package</summary>
    <releaseNotes>Artifact Information
  TwinCAT-XAE-PLC-Lib-Tc2_Math 3.4.4+76e0a95d
  Setup 1.0.1.10+0b47908d</releaseNotes>
    <copyright>(c) Beckhoff Automation GmbH &amp; Co. KG</copyright>
    <tags>Beckhoff TwinCAT XAE PLC Library Tc2_Math Setup InstallationLevel1 AllowMultipleVersions</tags>
    <docsUrl>https://infosys.beckhoff.com/</docsUrl>
    <dependencies>
      <dependency id="TwinCAT.Prep" version="0.0.0" />
    </dependencies>
  </metadata>
</package>

using this and adapting to your needs should work as the NuGet Server implementation is basically the same as the Beckhoff Server implementation in Twinpack.

Just make sure that the Tag after "Library" (in and ) is the title of your library (as in your .library file) - this little annoyance will be removed in one of the next patches of Twinpack, since for .library files we can actually get the title directly from the file.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/ThatsFokus"><img src="https://avatars.githubusercontent.com/u/57752925?v=4" />ThatsFokus</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <blockquote> <p>Not sure where the „Small“ and „Library“ tag in your screenshot are coming from with this nuspec</p> <p>anyway, we‘ll write some documentation how to publish a nuget package which is useable with Twinpack. Just a bit busy at the moment</p> </blockquote> <p>After revision I've seen "Small CountDown Library" is the description in tags there is only "plc-library"</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/iadonkey"><img src="https://avatars.githubusercontent.com/u/84121166?v=4" />iadonkey</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Anyway use</p> <p><code>Library <Title of your library></code> in the <code>tags</code> and the <code>title</code> and it should work</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/dfreiberger"><img src="https://avatars.githubusercontent.com/u/3814449?v=4" />dfreiberger</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@ThatsFokus regarding logging in to Azure DevOps artifacts server, I was able to do so by using my email and a PAT (personal authentication token) which I generated in Azure DevOps. I did not modify any configuration files in Twinpack and just logged in when prompted.</p> <p>I also ran into an issue after connecting where I couldn't see packages that I had published. After troubleshooting it looks like the Published field is not populated by Azure DevOps Artifact feeds, but is used in Twinpack.</p> <p>I modified <a href="https://github.com/Zeugwerk/Twinpack/blob/main/TwinpackShared/Protocol/Nuget/NugetServer.cs#L122">https://github.com/Zeugwerk/Twinpack/blob/main/TwinpackShared/Protocol/Nuget/NugetServer.cs#L122</a> to the below and the packages showed up.</p> <pre><code class="language-csharp">new Tuple<IEnumerable<CatalogItemGetResponse>, bool>( results.Select(x => new CatalogItemGetResponse() { PackageId = null, Name = x.Identity.Id, DistributorName = x.Authors, // Description = x.Description, Beckhoff's descriptions are meh IconUrl = x.IconUrl?.ToString() ?? IconUrl, RuntimeLicense = 1, DisplayName = x.Identity.Id, Downloads = x.DownloadCount.HasValue ? (int)x.DownloadCount.Value : 0, // Added null check Created = x.Published?.ToString() ?? "Unknown", // Added null check Modified = x.Published?.ToString() ?? "Unknown" // Added null check }).ToList(), results.Any()); </code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/iadonkey"><img src="https://avatars.githubusercontent.com/u/84121166?v=4" />iadonkey</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>fixed with release 1.0.8</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>