Is there a way to get the release/published dates of nuget packages? I've searched the nuget commands and VS powershell scripts but am coming up empty. I can't even find it on nuget.org, which gives abstractions like 'one month ago' instead.
I would prefer a programmatic way to retrieve this info. But I'll settle for any way at all.
Use the NuGet SDK. I've modified the code to display the Published property.
ILogger logger = NullLogger.Instance;
CancellationToken cancellationToken = CancellationToken.None;
SourceCacheContext cache = new SourceCacheContext();
SourceRepository repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json");
PackageMetadataResource resource = await repository.GetResourceAsync<PackageMetadataResource>();
IEnumerable<IPackageSearchMetadata> packages = await resource.GetMetadataAsync(
"Newtonsoft.Json", // replace with the required package id
includePrerelease: true,
includeUnlisted: false,
cache,
logger,
cancellationToken);
foreach (IPackageSearchMetadata package in packages)
{
Console.WriteLine($"Version: {package.Identity.Version}");
Console.WriteLine($"Publish date: {package.Published}");
}
Related
I am working on a flutter project that runs fine in development.
However I do not know how to get the build to include dll's referenced using FFI.
I can't find clear instructions on how to do it.
I tried following the steps to build an msix here, which worked but didn't seem to include the dll (it fails in the same way as the regular build)
what is the procedure to have the build process consider the dll's?
other dll's show up in the build directory from 3rd party packages so there must be a way right?
That's really hard to discover by your own, but indeed you can bind those libraries to you MSIX. In my case I just made a package for label printers using Dart FFI and DLL`s provided by manufacturer and this is how I did it.
You need to add these DLL's to your assets setting on pubspec.yaml from your package. This is my case:
[...]
flutter:
[...]
assets:
- assets/WinPort.dll
- assets/Winppla.dll
- assets/Winpplb.dll
- assets/Winpplz.dll
With this setting you will embed your DLL files in your final MSIX, but this was the easy part. Now you have make sure to load the proper load these files in code.
Based on my own tests, I still dealing with two ways to develop and test code, the first one is when I am running a project in my machine via flutter run I must set the target for current.path, when I get it done and start building for deploy I change this to resolvedExecutable.parent.path. Where is what you need to do.
Loading you DLL in development environment (flutter run):
final String _packageAssetsDirPath = normalize(join(Directory.current.path,'assets'));
On production environment (running from .exe or MSIX installed):
final String _assetsPackageDir = normalize(
join('data', 'flutter_assets', 'packages', 'YOUR_PACKAGE_NAME', 'assets'));
final String _exeDirPath = File(Platform.resolvedExecutable).parent.path;
final String _packageAssetsDirPath =
normalize(join(_exeDirPath, _assetsPackageDir));
After with this var called _packageAssetsDirPath will be easy to load your DLL's, now you invoke a DynamicLibrary constructor:
// Path for DLL file
final String _libDllSourceFullPath =
normalize(join(_packageAssetsDirPath, 'Winppla.dll'));
// Target for copy, place DLL in same place the .exe you are running
final String _libDllDestFullPath =
normalize(join(_packageAssetsDirPath, 'YOUROWN.dll'));
// Try to copy for running exe path
File(_libDllSourceFullPath).copySync(_libDllDestFullPath);
// With this copy, would be simple to load, and if it fails, try in full path
// LOAD DLL
try {
String _packageAssetsDirPath =
normalize(join(Directory.current.path, 'assets'));
String _printerLibraryPath =
normalize(join(_packageAssetsDirPath, 'Winppla.dll'));
DynamicLibrary _library = DynamicLibrary.open(_printerLibraryPath);
return _library;
} catch (e) {
try {
DynamicLibrary _library = DynamicLibrary.open('Winppla.dll');
return _library;
} catch (e) {
// Avoing errors creating a fake DLL, but you could deal with an exception
return DynamicLibrary.process();
}
}
At this point you can load a DLL and use it, you can check my package full code at https://github.com/saviobatista/argox_printer check for lib/src/ppla.dart at function _setupDll() and you will see that loading.
I built a simpler option inspired in the solution of Sávio Batista
(You must have your .dll in your assets folder)
if (kReleaseMode) {
// I'm on release mode, absolute linking
final String local_lib = join('data', 'flutter_assets', 'assets', 'libturbojpeg.dll');
String pathToLib = join(Directory(Platform.resolvedExecutable).parent.path, local_lib);
DynamicLibrary lib = DynamicLibrary.open(pathToLib);
} else {
// I'm on debug mode, local linking
var path = Directory.current.path;
DynamicLibrary lib = DynamicLibrary.open('$path/assets/libturbojpeg.dll');
}
Just replace libturbojpeg.dll for your .dll
I am trying to write a PowerShell script which help developer to check-in their changes via PowerShell ISE and link the changeset to work item. I have TFS 2017 and TVFC is configured.
This can't be dont through tc vc commands, but since PowerShell can load the TFS Client Object Model, it's easy to use that to set some properties on the pending changes. You can use the VersionControlServer class to access the WorkSpace and associate the workitems using the WorkspaceCheckinParameters.AssociatedWorkItems class.
var checkinParameters = new WorkspaceCheckInParameters(changes, comment)
{
AssociatedWorkItems = ... <- Associate your work items here
};
return _workspace.CheckIn(checkinParameters);
I have a module, built with Dist::Zilla. I have Dist::Zilla set up to automatically push changes out to my GitHub repo. Works great when the repo is private.
However, as soon as I make the repo public, I start getting errors during the build process. Specifically, these lines in the dist.ini
[Bugtracker]
web = http://github.com/myaccount/%s/issues
If I comment out these lines, it works. With these lines left in, I get an error:
Duplication of element resources.bugtracker.web at /Users/me/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.4/Dist/Zilla.pm line 595.
OK, so fine, I comment out the lines. However, another problem crops up. The version number of my builds no longer autoincrements and is stuck at the same number every time I try to release a build.
Is there some configuration setting I need to change with Dist::Zilla so it will play nice with public github repos? Here is the full dist.ini file:
name = Module-Test
author = me
license = Perl_5
copyright_holder = Me
copyright_year = 2018
[Repository]
;[Bugtracker]
;web = http://github.com/sdondley/%s/issues
[Git::NextVersion]
[GitHub::Meta]
[PodVersion]
[PkgVersion]
[NextRelease]
[Run::AfterRelease]
run = mv Changes tmp && cp %n-%v/Changes Changes
[InstallGuide]
[PodWeaver]
[ReadmeAnyFromPod]
type = markdown
location = root
phase = release
[Git::Check]
[Git::Commit]
allow_dirty = README.mkdn
allow_dirty = Changes
allow_dirty = INSTALL
[Git::Tag]
[Git::Push]
[Run::AfterRelease / MyAppAfter]
run = mv tmp/Changes Changes
[GatherDir]
[AutoPrereqs]
[PruneCruft]
[PruneFiles]
filename = weaver.ini
filename = README.mkdn
filename = dist.ini
filename = .gitignore
[ManifestSkip]
[MetaYAML]
[License]
[Readme]
[ExtraTests]
[ExecDir]
[ShareDir]
[MakeMaker]
[Manifest]
[TestRelease]
[FakeRelease]
Your [Bugtracker] entry leads to duplication because you are also setting the bugtracker through [GitHub::Meta]. Choose one or the other.
As for version number management, note that [Git::NextVersion] is based on your git tags. Make sure that these tags are present in your local repository and have the correct format. That plugin uses a command line invocation similar to this to obtain all tags:
git rev-list --simplify-by-decoration --pretty=%d HEAD | grep -oE 'tag: [^,)\s]+'
Public GitHub repos should not be a problem for Dist::Zilla – this is exactly the setup most dzil distros use anyway. But interactions between multiple plugins can lead to hard to track down bugs, especially since the order of plugins is important. It can help to organize your plugins by the phase in which they run, and to test whether the problem persists after removing optional plugins. It also tends to be better to start with a simple dist.ini and add plugins as pain points in your development process become apparent.
I have a package in a private package feed of my Visual Studio Team Services (VSTS) account and want to unlist all versions of my package since it's deprecated and has been superseded by a different package.Thus I want to mark the old package as deprected by unlisting it (not deleting it, if possible)
Unfortunately all I can find is a button that unlists one specific version of the package, like described here. Removing my legacy package that way takes ages since I have to unlist easily 30 versions before the package is removed from my feed.
I know that nuget.org has the functionality to unlist all versions of a package with just one click and I'd consider it to be a basic function. Does anyone know whether there's a trick or hidden button that allows me to unlist packages more easily in VSTS? Or is there maybe a nuget cli command for that?
No matter by VSTS web UI or nuget cli, the packages can only be unlisted one by one.
The format for unlist a package as:
nuget delete <packageID> <packageVersion> [options]
But you can write your own script to unlist packages in your VSTS feed in loop. Detail steps as:
1. Add the VSTS feed as source with credential
nuget sources add -Name "feedname" -Source "https://account.pkgs.visualstudio.com/_packaging/feedname/nuget/v3/index.json" -Username <Alternate username/email> -password <Alternate password/PAT>
2. List all the packages in the VSTS feed
nuget list -source feedname -AllVersions
3. Loop the packages you get in step2, and unlist them in the loop
nuget delete packagename packageversion -source feedname -ApiKey key
The TFS Packages UI allows you to multi select and unlist using CTRL or SHIFT type selects. I use that to unlist and promote packages.
no script needed to unlist all packages.
it can be done in few clicks in UI:
go to your Devops UI
open the nuget repository
then go to Artifacts/Packages
select the your package
open Versions tab
tick the first record in the list (so you will see a round tick next to it)
scroll down to the end of the list and tick the last record while you holding Shift key
select Unlist at the top menu
IMPORTANT NOTE: at the moment of writing there is a bug in Devops UI: if you select more than 100 records, Unlist command does not do anything. So you may need to select records in batches of 100 records (or less) to make it work!
I've created and used the following powershell script to unlist all nuget packages from my tfs feed.
$nugetFeed = "http://tfs/MyTeam/_packaging/MyProject/nuget/v3/index.json"
$nugetExe = "C:\pathToNuget\nuget.exe"
$packageToDelete = "MyPackage"
$apiKey = "VSTS"
function Get-PackageVersions
{
Param
(
[string]$Package,
[string]$Feed,
[string]$Nuget
)
$packageContent = & $Nuget list -Source $Feed -PreRelease -AllVersions
$packages = $packageContent.Split([Environment]::NewLine)
foreach($line in $packages) {
$parts = $line.Split(' ')
$packageName = $parts[0]
$packageVersion = $parts[1]
if($packageName -eq $Package) {
$packageVersion
}
}
}
$versions = Get-PackageVersions -Package $packageToDelete -Feed $nugetFeed -Nuget $nugetExe
foreach($version in $versions) {
& $nugetExe delete $packageToDelete $version -Source $nugetFeed -ApiKey VSTS $apiKey
}
If you need the same thing for nuget, and came here from google you can also use this:
dotnet tool install --global NugetUnlister
and then
nuget-unlist drop PrereleaseBefore -p Some.Package --sv [0.1.3] -k somekey
For whoever wants to do it via the DevOps UI. I wrote that little console script that marks up to 100 versions (limit by UI) which you then can unlist. If you increase the scroll counter you wont need to start always over again ;)
it does scroll down automatically und waits for the entries to load.
(() => { let view = document.getElementsByClassName('vss-PivotBar--content')[0]; let scroll = 0; let markedElements = 0; let doit = () => { if(view.scrollTop + 500 < view.scrollHeight && markedElements < 100) { console.log('i did scroll to: ' + scroll); let list = document.getElementsByClassName('ms-List-cell'); for (var el of list) { if(el.getElementsByClassName('strike-through').length == 0) { let btn = el.getElementsByClassName('ms-Check')[0]; if(btn.className.indexOf('is-checked') == -1 && markedElements < 100) {btn.click(); markedElements++;} } }console.log(markedElements); scroll++; view.scrollTo(0, 500 * scroll); setTimeout(()=>doit(), 2000); }}; doit(); })()
I have a Source DacPac and a Target DacPac. With powershell I would like to compare both and generate a upgrade script. This per se is simple for all cases with DacServices as long as there is a valid Connection String. However, for my CD pipeline, I do not know the eventual connection string nor do I wish to know. And all I want is for the script to generate the SQL.
I tried this out with sqlpackage.exe by sending args as follows
$args = #(
"/a:Script",
"/sf:$PathToDacpacSource",
"/tf:$PathToDacpacTarget",
"/op:$outputFile",
"/tdn:$TargetDatabaseName"
)
and this works fine. so far I had managed by adding just a dependency to DacServices via [Microsoft.SqlServer.DacFx.x64], but this inability to generate scripts without a connection string has forced me to add the dependency on SQLPackage.exe via [Microsoft.Data.Tools.Msbuild] too
The constructors for DacServices all require a ConnectionString
Has anyone else encountered a similar situation and any solutions?
or Do you exclusively use SQLPackage at the deployment side to overcome this issue?
There is a static version of GenerateDeployScript that does not need a connection string as you don't call the constructor for a static method, it isn't very clear in the msdn documentation but the "S" which looks like it is floating means it is static :)
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dac.dacservices.generatedeployscript(v=sql.120).aspx#M:Microsoft.SqlServer.Dac.DacServices.GenerateDeployScript%28Microsoft.SqlServer.Dac.DacPackage,Microsoft.SqlServer.Dac.DacPackage,System.String,Microsoft.SqlServer.Dac.DacDeployOptions%29
` public static string GenerateDeployScript( DacPackage sourcePackage, DacPackage targetPackage, string targetDatabaseName, DacDeployOptions options = null )