NuGet Package Manager to manage packages fills hard drive over time - nuget

I have an application that uses NuGet packages to manage versions of tooling available to an instance of the application.
For instance, A Test Manager, the actual Tests that are executed by the Manager are contained in a .nupkg file. If you want to change which tests are executed all you have to do is replace the .nupkg file. When the application runs it finds the package and uses the package manager to get all the files out and add them into my app domain.
The package manager extracts all the files into a temp folder and returns the directory they were extracted to.
Unfortunately every time the application runs it extracts to a new random location because of this block of code in OptimizedZipPackage:
protected virtual string GetExpandedFolderPath()
{
return Path.GetRandomFileName();
}
Yes it is virtual and I can override it in my own version of the package, but in order to use my own version of the package I also have to have my own version of the LocalPackageRepository class, with an override.
What I'm hoping for is an way to get fixed folder names so it uses the same folder for the same package/version every time without having to write override classes.

Related

Nuget.exe - IS there any way to download nuget package (.nupkg) directly from Website?

I have created nuget package (.nupkg) and hosted that package directly on one of http servers
http://someserver/location/sub-location/nuget/MyPackage.1.0.0.nupkg
So if i just copy paste this URL in browser, packages gets downloaded immediately.
But, I want to download this package as part of nuget restore command.
I have used section in nuget.config file to download package from Folders, nuget.org, artifactory etc. But this particular case not working.
I don't want to run additional command to download package (for example, i don't want to use Curl )
I want some configuration done so that i can download this package in same way as other packages from other nuget repositories .
I don't want to run nuget server for hosting.
Thanks,
Atul
Sleet is a static NuGet feed generator. Using it, you can generate files and use any web server to serve static files.
However, since this includes a static response to search queries, if anyone uses this feed with Visual Studio's Package Manager UI, it doesn't matter what search terms they type, they'll always get the same search results. When VS searches a package source, it requests a maximum of 25 results, but since Sleet is static, it returns the entire list of every package in the feed. Before Visual Studio 2019 16.7, NuGet would show all the search results and if the Sleet feed contained enough packages, it would crash VS with an out of memory exception. VS was changed to only take the first 25 results and ignore the rest, so it will no longer crash. But this means that it's impossible now in PM UI to see more than the first 25 packages. If search results are not important to you, the Sleet sounds like a good fit.

Nuget package missing .target file in build folder

I have build a nuget package at published it to a nuget.server site. But when I try to use the package form the server the .targets file from build folder is not in the file. But if I use the package from a local folder it works as it should. How do I get it to work ?
If i look in the package in the folder on the server it looks ok.
It's not clear to me if you mean using (referencing and restoring) a package, or building (packing) a package.
If the problem is with packing the nupkg, NuGet requires the props and targets files to have specific filenames in specific folders, but if you got it to work at least once, you probably already know that. If this is not the problem with packing, you need to give us more information because not using the correct filename convention is the most common problem and I can't guess what else the problem could be. In particular, if the package is being packed differently on your local machine compared to when it is packed on the server, it means there is something different between how you pack on the two computers, so we need more information about how the build and pack work with your project.
If the problem is with using (restoring) the package, there are a few possibilities. My best guess is that you once had a package without the targets file working correctly, and you restored the package on the server. By design, NuGet packages are immutable which means it's invalid for the contents of a package (same ID and version) to change. This allows NuGet to download the package from a remote feed once, save it in the global package folder (not a cache; they never expire) and the next time NuGet needs to restore the same package (id + version) it uses the one in the global package folder, it does not download again. This means if you once built a bad nupkg and restored it on a machine, then fix the nupkg and kept the same version number, that machine will never get the fixed nupkg. You need to delete it from the global packages folder. I'm not 100% sure, but I think if you have a local file feed and you restore a project that uses packages.config, the nupkg does not get saved in the global packages folder, so doesn't have the same problem. In short, I think the problem is that you changed the nupkg contents once without changing the version number, and one of the machines has the old copy in its global packages folder that it keeps using.
If that's not the problem, the next most likely cause is that the nupkg on the server feed has different contents to the nupkg in the local feed. I've never used NuGet.Server, but some nuget respositories (like nuget.org) do not allow overwriting nupkgs. So, if you pushed a nupkg to your server, fixed a problem in your nupkg without changing the version, then tried to push again, the second push might have failed.
In summary, your question doesn't provide enough information for us to help you, but I wrote about the most common issues above. If it doesn't help, you need to provide us with more information. An example of the problem is the best way to give us enough information to help you.

Packaging SF service into a single file

I am working through how to automate the build and deploy of my Service Fabric app. Currently I'm working on the package step and while it is creating files within the pkg subfolder it is always creating a folder hierarchy of files, not a true package in a single file. I would swear I've seem a .SFPKG file (or something similarly named) that has everything in one file (a zip maybe?). Is there some way to to create such a file with msbuild?
Here's the command line I'm using currently:
msbuild myservice.sfproj "/p:Configuration=Dev;Platform=AnyCPU" /t:Package /consoleloggerparameters:verbosity=minimal /maxcpucount
I'm concerned about not having a single file because it seems inefficient in sending a new package up to my clusters, and it's harder for me to manage a bunch of files on a build automation server.
I believe you read about the .sfpkg at
https://azure.microsoft.com/documentation/articles/service-fabric-get-started-with-a-local-cluster
Note that internally we do not yet support provisioning a .sfpkg file. This is a feature that will be coming in soon (date TBD). Instead, we upload each file in the application package.
Update (SF 6.1 - April 2018)
Since 6.1 it is possible to create a ZIP file (*.sfpkg) and upload it to an external store. Service Fabric executes a GET operation to download the sfpkg application package. For more infos see https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-package-apps#create-an-sfpkg
NOTE: This only works with external provisioning, the Azure image store still doesn't support sfpkg files.

How to upload Parent child SSIS package to server

Hi all I am very new to SSIS. I have got SSIS package developed by some other guy this package reads data from flat files and stores to database after mapping.
Flow:
1) First package extract records from flat file and stores in table.
2) Then it calls child package using Execute package tasks.
3) Then child package do some calculations and update the database table.
SSIS is using Environment variable to get database information.
Every thing is working fine but now I want to deploy this package to my client's server.
Ques: Do I need to copy and paste files from bin folder and paste on clients machine?
What I Tried: I copy files from bin folder and placed on my local computer. Then I create a job in MSSQL and run the job. Package runs perfectly. But Later I changed location of my project and problem starts job stops working.
Issue: Error says location of child package is not available(As I changed position of my project files)
Kindly suggest what to do.
I am going to make several assumtions here so please correct me if I get any wrong.
The problem I am guessing is that on your Package.dtsx within the connection manager this is currently linked to the package location within the project folder. In this case you are wanting to change it to another location, however the package in the connection manager is still pointing to the project location.
If I were you I would do the following:
Create a string variable
PackageFolderPath - C:\CurrentPackagePath\DBPackage.dtsx
Now what you want to do is go to the package within the connection manager and under the properties add an expression for ConnectionString with the following: “#[User::PackageFolderPath] If you evaluate the expression it should give you the location you setup in your variables.
Please note however that if you want this to work on the development system then setup the package to the project location.
Now once you have those setup, copy the files across the new server and under the SQL agent job to go the Set Values tab and within here you want to add the following:
\Package.Variables[User::PackageFolderPath].Properties[Value]
Under the value you want to put wherever the package is now located
This now should pickup the new location of the package when it is run.
A better way to do this would be to make use of the deployment utility and using an XML configuration variable on the package. However this way should work.

Install NuGet package programmatically

I'm trying to install a simple nuget-package programatically. I have created a package with a Site.css file in it. So it resides in the content folder of the package.
Using this code
public void TestInstall(string packageID, string physicalPath)
{
var rep = PackageRepositoryFactory.Default.CreateRepository(new PackageSource("http://nuget.testserver.lan/nuget", "Default"));
var packagemgr = new PackageManager(
rep,
new DefaultPackagePathResolver("http://nuget.testserver.lan/nuget"),
new PhysicalFileSystem(physicalPath)
);
var package = rep.FindPackagesById(packageID).First();
packagemgr.InstallPackage(package, false);
}
Lets say I provide packageID = 'Testpackage' and physicalPath = 'c:\inetpub\test' it creates:
c:\Inetpub\test\Testpackage
and that folder contains:
the content folder with the Site.css AND the Testpackage.0.1.nupkg
Not quite what I'm trying to do but sort of :)
Is it possible to change it so:
I can specify where it should place the package for its cache-functionality
Make it place whatever resides in the content folder to the specified path?
If the package contains dll's in the lib-folder have them go in the bin-directory (create if not exist)
A lot of the functionality of NuGet currently relies on Visual Studio automation, so outside of VS it's difficult to get all of the same behaviour.
Lot of people have asked for functionality that would require changes from using VS automation, so I suspect it's probably on the roadmap, as it's significant work, I don't think it will be soon.
Don't forget you can install packages in the Visual Package Manager console, so it's only a single command (Install-Package MarkdownHelper) and doesn't require clicking through the UI.