What is the difference between pubspec.yaml and pubspec.lock? Both are holding the dependencies versions.
The first time you get a new dependency for your package, pub downloads the latest version of it that’s compatible with your other dependencies. It then locks your package to always use that version by creating a lockfile. This is a file named pubspec.lock that pub creates and stores next to your pubspec. It lists the specific versions of each dependency (immediate and transitive) that your package uses.
~ source
In pubspec.yaml there are only packages and versions, which you need to use. In pubspec.lock there are also packages and versions which you need and which each of package that you use needs.
The pubspec.yaml file is used to declare the dependencies and configuration for a Dart package, while the pubspec.lock file is automatically generated by the Pub package manager to lock the version of each dependency used in the project.
The pubspec.lock file ensures that all members of a team, or a CI/CD pipeline, use the same dependencies, preventing version conflicts and ensuring the reproducibility of builds.
The pubspec.yaml file is manually maintained and can be changed to update the project's dependencies or configuration.
Related
I have an F# project that uses FSharp.Core version 4.1.0. When I upgrade to version 4.1.12, NuGet adds the following files to my project's source code directory:
any/netstandard1.6/FSharp.Core.sigdata
any/netstandard1.6/FSharp.Core.optdata
I expect NuGet to add files under the packages directory, not directly into my project. Having these files appear alongside .fs files in the project's source code tree seems odd. Is this expected behavior? Can I safely delete these files (since copies presumably exist under packages as well)?
Here's an example of what I see:
What is the difference in dependencies and dev_dependencies in a pubspec.yaml? It seems that when I run pub get the dev_dependencies aren't downloaded.
dev_dependencies are dependencies that are not available for code in the resulting application, but only for tests, examples, tools, or to add executable tools like for code generation to your project.
dev_dependencies of any dependencies in your project (dependencies or dev_dependencies) are always ignored when you publish to pub.dev.
See also https://dart.dev/tools/pub/pubspec
There are two types of dependencies, one is regular and the other is dev.
dependencies:
Regular dependencies are listed under dependencies:—these are packages that anyone using your package will also need.
dev_dependencies:
Dependencies that are only needed in the development phase of the package itself are listed under dev_dependencies.
If your package (say A) depends on another package (say B) (which has dev-dependencies), then your package A ignores the dev-dependencies of package B.
However, your package A depends on the packages listed by Package B's dependencies.
Pub supports two flavors of dependencies : dependencies and dev dependencies.
Dev dependencies differ from regular dependencies in that dev dependencies of packages you depend on are ignored.
Here’s an example:
Say the transmogrify package uses the test package in its tests and only in its tests. If someone just wants to use transmogrify—import its libraries—it doesn’t actually need test. In this case, it specifies test as a dev dependency.
Its pubspec will have something like:
dev_dependencies:
test: '>=0.5.0 <0.12.0'
Pub gets every package that your package depends on, and everything
those packages depend on, transitively. It also gets your package’s
dev dependencies, but it ignores the dev dependencies of any dependent
packages. Pub only gets your package’s dev dependencies. So when your
package depends on transmogrify it will get transmogrify but not test.
The rule for deciding between a regular or dev dependency is simple: If the dependency is imported from something in your lib or bin directories, it needs to be a regular dependency. If it’s only imported from test, example, etc. it can and should be a dev dependency.
Using dev dependencies makes dependency graphs smaller. That makes pub run faster, and makes it easier to find a set of package versions that satisfies all constraints.
Here, You can learn more about dependencies
I have a mvc 5 web project with a number of NuGet packages installed (like email, log, pagedlist etc).
In a new similar project I would like to install the same NuGet packages. How can I in the old project list all installed NuGet packages?
You can find a packages.config file in the old project's root directory.
You can copy it to the new project.
If you go to Tools -> NuGet Packet Manager -> Packet manager settings and check Allow NuGet to download missing packages and the other check box that states Automatically check for missing packages during build in Visual Studio it will download it for you next time you build.
If you want to list all installed nuget packages for the project take a look at this one.
http://blogs.msdn.com/b/david_kidder/archive/2014/08/19/micro-blog-how-to-list-installed-nuget-packages-from-package-manager-console-and-be-able-to-read-them.aspx
You might also want to enable nuget package restore to restore the packages when rebuilding your project/s.
Here's another link for you - http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
In the root folder of your original project find a packages.config file. Copy its contents to your new project, same file name.
Go to Visual Studio > Tools > Package Manager Settings > General
Enable "Allow Nuget to download..." and "Automatically check for missing..."
Now build your new project
Most of the answers here are partially correct.
The first part is true. The packages.config file lists all packages that are used by the project.
However, all the answers about using Package Restore are incorrect. Package Restore will download any missing packages, however it is NOT the same as installing a package into a project. It will not add references, run any install.ps1 scripts, or add files, modify .config, etc. Package Restore simply downloads missing packages. It is assumed that the packages were already installed to the project.
In order for the packages to be correctly installed in your new project, open the Package Manager console, then type:
Update-Package -ProjectName MyProjectName -Reinstall
This will force NuGet to run through the install process and correctly install the package into your project.
I have the bower.json file in my main app directory (of my node and angular apps).
Then in the bower_components directory there are in each respective component/module another bower.json file.
Why are they needed?
Each bower dependency you import in your project is a complete module that you will depend on. Therefore this component must have a name, a version and may come with its own bower dependencies too, that's what the bower.json is for.
It's like a big tree of packages linked by dependencies where your application sits on top.
You can read the official documentation to learn more on the bower.json file and see all the options available.
Does anyone know how to update dUnit which comes with Delphi 2010 to the latest svn source code?
Steps
Goto http://sourceforge.net/projects/dunit/
Download the zip file (currently version 9.3.0)
Unpack to a folder of your choice
Use Components|Install packages to remove the current DUnit package bpl.
Compile and install (optional) the new version. Compilation is needed only if you want to install the design time wizards or if you do not build your projects using the source. Installation is only needed if you want to use the design time wizards. Read the various doc and readme files for further instructions.
Update your environment's library path and the search paths of projects using DUnit:
take out any references to $(BDS)\source\DUnit*
put in a reference to the src subfolder of where you installed the new version
Update
The latest version on sourceforge is 9.3.0, but that is not the latest DUnit version. To get the latest DUnit version, you can go to its SVN repository: https://dunit.svn.sourceforge.net/svnroot/dunit/trunk/
The are at 9.4.0 (revision 41 according to the top of the page, version found in readme-9.4.txt and release.ini).
The sources found there do not contain any packages for Delphi versions past D7, but as mentioned in my response to Serg, these packages are for the DUnitWizards which were contributed from outside the main DUnit project. To use DUnit, you don't need these wizards. In fact, DUnit itself does not have any packages!
I think you can still use the wizards (or should I say project/unit templates) that come standard with Delphi and just make sure that your library and search paths point to the new version... In fact, I know you can, because that is what I did a couple of days ago: use the File|New|Other|Unit test| project and unit templates that come standard with the IDE, but compile against the newest sources downloaded from SVN.
You can either unregister current DUnit package by removing its key from Registry:
HKCU\Software\CodeGear\BDS\7.0\Known IDE Packages\$(BDS)\Bin\unittestide140.bpl
Then download and install the new version from any folder you want, into the IDE as you install any other IDE package.
Or you build the new version, copy the generated BPL file to $(BDS)\bin\ folder, and its .DCU files to $(BDS)\Lib\ folder, and replace $(BDS)\Source\DUnit folder with the source folder you downloaded from SVN.