What's the difference between pub dependencies and dev_dependencies? - dart

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

Related

Difference between pubspec.lock and pubspec.yaml

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.

Install Scandit fail. The package does not contain any assembly references or content files that are compatible with that framework

I am trying to install nuget package "Scandit" to my project.
IDE: Visual studio Mac(Xamarin.Forms 4.6.0.726)
The following is the error message.
Attempting to gather dependency information for package 'Scandit.BarcodePicker.Xamarin.5.14.5.10' with respect to project 'Modbusbutton3', targeting '.NETPortable,Version=v4.5,Profile=Profile78'
CACHE https://api.nuget.org/v3/registration5-gz-semver2/scandit.barcodepicker.xamarin/index.json
Total number of results gathered : 52
Gathering dependency information took 217.67 ms
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json - 5.27 ms
Attempting to resolve dependencies for package 'Scandit.BarcodePicker.Xamarin.5.14.5.10' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Scandit.BarcodePicker.Xamarin.5.14.5.10'
Resolved actions to install package 'Scandit.BarcodePicker.Xamarin.5.14.5.10'
Found package 'Scandit.BarcodePicker.Xamarin 5.14.5.10' in '/Users/dej.pvi/Downloads/20200506-WiFi Solution for iOS/packages'.
For adding package 'Scandit.BarcodePicker.Xamarin.5.14.5.10' to project 'Modbusbutton3' that targets 'portable45-net45+win8+wp8'.
Install failed. Rolling back...
Package 'Scandit.BarcodePicker.Xamarin.5.14.5.10' does not exist in project 'Modbusbutton3'
Executing nuget actions took 15.64 ms
Could not install package 'Scandit.BarcodePicker.Xamarin 5.14.5.10'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Can any one help how to solve this? Thank you!
As I checked Scandit.BarcodePicker github sample they are using two different packages.
Scandit.BarcodePicker.Xamarin
This package is installed only in Android and iOS project.
Scandit.BarcodePicker.Unified
This package is installed in every project.
According to your log Target Framework of your project is PCL. You might consider to convert you project to .NETStandard 2.0, because this might be other issue why you are not able to install this package. Check the link here.

Upgrading Typescript Compiler for Visual Studio Project

I have an existing ASP.NET MVC project which uses typescript version 0.8 and I need to upgrade it to 1.5.
During the time of version 0.8 there was no <TypeScriptToolsVersion> element in the .csproj file but the following exists
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>
So my question is this:
If I include <TypeScriptToolsVersion>1.0</TypeScriptToolsVersion> do
i still need <TypeScriptTarget>ES5</TypeScriptTarget>. I'm not sure if TS versions 1.0 -
1.5 above has the option to select specific ES version or it will just default to ES6.
How do i know which Typescript version my
typings uses (ex. jquery.d.ts). I can't seem to find anything in the
source file that specifies its TS compiler version even looking at
the github repo doesn't indicate its compiler requirements.
Finally is there anyway to integrate the TS compiler in the project. We are using TFS Integration and we are not including the outputted js files (only the .ts) so we need to compile it during deployment. I could request for our devops to install the TS compiler in all our environments but that seems tedious. Using grunt may not work as well cause it would require me to request to install node in the prod environment. Any good approach would be appreciated.
Yes tsc has option to select target since 0.8 to newest version. Default value is ES5 - I think in older version default was ES3.
I just believe that typings authors create most compatible definitions possible. tsd is not versioned therefore you can only rely on build errors...
Only deployment environments need to have tsc installed. You can install VS extension, use tsc itself (needs node) or use tools like grunt/gulp with some TS plugin. But in prod environment you don't need VS/node - it should use deployed version of the product with js files.

How list/remove globally installed Dart dependencies?

I try to figure out how to manage pub packages. For example, I have the following pubspec.yaml:
name: app
dependencies:
intl: any
browser: any
polymer: any
transformers:
- polymer
After time I consider to remove intl package. As far as I understand running pub get again automatically remove unused packages (to be more precise it removes links but not actual files). If so how can I list/remove actual packages available globally (on Ubuntu under /home/username/.pub-cache/hosted/pub.dartlang.org/)?
Use the den tool. It's a community-contributed tool that provides various utilities for working with pub packages.
den uninstall thing_i_do_not_need_anymore
Only manually by deleting them using your OS tools. There is no pub ... support for that.
pub ... only works for the current project (current working directory) and it doesn't know if versions are used by other projects on your disk.

What project options to use for open source Delphi packages?

I've written some Delphi code I would like to share on GitHub. All code is contained in runtime and designtime packages as required. There are many "Project Options" to set for each project. (Output directories, search paths, compilation options, etc.) I've managed to find some default options that work well for my situation but reading other Q&As here it's clear there are multiple ways of working.
What project options should be used to allow the open source packages to easily be incorporated into individual projects?
I've recently started using NodeJS. The NPM package manager makes it super easy to use third-party packages in a project. Packages are installed with one simple command on the command line. Packages will automatically install any required dependencies.
PS: Feel free to edit this question if you would like to add extra things to consider.
Let's say you have this structure
MyComponent
Packages
DelphiXE7
Package2.dpr
source
bin
Delphi XE7
then set
Search Path
..\..\..\source
Unit output directory
..\..\..\bin\Delphi XE7\$(Platform)\$(Config)
After compilation for all supported platforms and both Release and Debug you will have this structure in the bin directory
MyComponent
Packages
DelphiXE7
Package2.dpr
source
bin
Delphi XE7
Android
Release
Debug
Win32
Release
Debug
Win64
Release
Debug
For installation you have to setup some path inside the IDE.
Environment
MYCOMPONENT => [root path to the files]
Library
Repeat that for all supported platforms
Library Path
$(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Release
Search Path
$(MYCOMPONENT)\source
Debug-DCU-Path
$(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Debug
If there are some language related units there is also a place to add (see Library - translated)
This ensures, that you have full debug feature (with Use Debug-DCU option set) and on release you have no debug code in your application.
Just a sidenote on libraries you should not want to install because you only use them in some projects.
Simply use the Optionset combined with a environment variable.
Here my SuperObject.optionset ($(USRLIB) points to a directory, where I collect all common used source code. And $(USRLIB)\ext is the place for all of the external libraries).
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DCC_UnitSearchPath>$(USRLIB)\ext\superobject;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
</PropertyGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>OptionSet</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality/>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>
To use the superobject library I simply add the optionset to the project (right mouse click on build configuration) and everything is fine.

Resources