Open Taritsyn opened 3 years ago
I like the idea of supporting platform selection better, also keen on adding macOS and linux binaries to any release channel - want it to be clear that ChakraCore is not just a windows option.
Note we also hope to be able to build ChakraCore on some extra platforms at some point, hopefully within the year but not sure (these capabilities do not yet exist):
That aside obviously we'll need to drop the Microsoft name from these packages - need to consider an appropriate alternative, possibly chakra-core (as that's our github org name now) though chakra-core.ChakraCore
is a bit of an odd package name.
One point that jumps out to me from reading through these examples is the sheer quantity of it - particularly with some duplication for the various components - if/when we need to update aspects of this would it be better to have a powershell or python script that produces all of these nuspec documents rather than updating them manually? (not sure if this is realistic at all but thought it worth mentioning).
@Fly-Style @ppenzin any thoughts on above?
@Taritsyn thank you for the detailed instructions. I agree we should do it (it would obviously be a pain, but we only have to do it once).
@rhuanjl regarding the package name, how about ChakraEngine.ChakraCore
or Chakra.ChakraCore
?
@rhuanjl
I like the idea of supporting platform selection better, also keen on adding macOS and linux binaries to any release channel - want it to be clear that ChakraCore is not just a windows option.
For .NET development, it is already standard practice to create separate packages with the native assemblies for each platform, but what about the C ++ package? Even now, the Microsoft.ChakraCore.vc140 package is quite heavy (it weighs more than 100 MB). and if you add binaries for the ARM64 processor architecture, then it will weigh even more. Most likely it should also be splited into several NuGet packages according to processor architectures, but in this case will have to extract the header files into separate package.
Note we also hope to be able to build ChakraCore on some extra platforms at some point, hopefully within the year but not sure (these capabilities do not yet exist):
At the moment, main problem is that by name of the directory into which the assemblies are copied, it is impossible to understand for which platform build was made:
out/Release/libChakraCore.so
out/Release/libChakraCore.dylib
That aside obviously we'll need to drop the Microsoft name from these packages - need to consider an appropriate alternative, possibly chakra-core (as that's our github org name now) though chakra-core.ChakraCore is a bit of an odd package name.
Usually, name of organization or project in the Pascal case style is used as NuGet package ID prefix. Since the organization is already registered on NuGet.org, then the answer is quite obvious.
A much more difficult problem is choosing a sub-prefix, since the sub-prefix for .NET and C ++ will be different. I would suggest the following prefixes and sub-prefixes:
.NET
ChakraCore
. Sub-prefix can be dispensed with, because NuGet was originally designed for .NET and most packages are considered .NET oriented by default.ChakraCore.DotNet
. This prefix makes it clear that the package is intended for .NET, but, at the same time, some people may think that this is a C# port of the ChakraCore library.ChakraCore.Native
. This prefix immediately makes it clear that the package contains the native assemblies, but, at the same time, some people may think that the package is intended for C++. C++
ChakraCore.Cpp
. It is immediately clear that the package is intended for C++. Such a prefix will be a good complement to the ChakraCore.Native
prefix.ChakraCore.v140
. Meaning of such a prefix will not be clear to everyone. ChakraCore.Cpp.v140
. A good combination of the previous two variants, which brings more specificity.
One point that jumps out to me from reading through these examples is the sheer quantity of it - particularly with some duplication for the various components - if/when we need to update aspects of this would it be better to have a powershell or python script that produces all of these nuspec documents rather than updating them manually? (not sure if this is realistic at all but thought it worth mentioning).
Good idea! Basically, I can write a script, that generates a temporary .nuspec
, .props
and .ps1
files based on data and templates, in cross-platform PowerShell.
I have already written about disadvantages of existing packages and gave several recommendations for improving it (see the “Recommendations for improving an existing NuGet packages for .NET projects” issue). In this post, I will write about more radical changes - new structure of NuGet packages. Currently, .NET developers using the ChakraCore library have only one official package available - Microsoft.ChakraCore, which has two significant disadvantages:
These problems can be solved by creating separate packages for each platform and converting the Microsoft.ChakraCore package to a metapackage. Some developers, including me, have done so by publishing their own packages: JavaScriptEngineSwitcher.ChakraCore.Native.*, BaristaLabs.BaristaCore.ChakraCore.* and ReactWindows.ChakraCore.ARM64. Appearance of official packages, created according to similar principles, would led to three positive points:
I will list the main steps that you need to do to create such packages (examples still use the old package naming system):
.nuspec
and.props
files are located in the same directory. It would be more optimal to create a separate directory for each package and move these files there. In the future, this would make it easier to add new files to packages (for example, PowerShell scripts)..props
files you need to use a code similar to code from theMicrosoft.ChakraCore.props
file..symbols.nupkg
) or new (.snupkg
) format. Therefore, to create a platform-specific “symbol” packages, we will use the same approach as in theMicrosoft.ChakraCore.Symbols
package: create a regular NuGet packages that will deploy the.pdb
files instead of the.dll
files..pdb
files on ASP.NET 4.X websites. Unfortunately, MSBuild scripts are not suitable for all use cases of .NET Framework. For example, ASP.NET 4.X web sites don't have project files and need to use a PowerShell scripts to deploy the native assemblies in thebin
directory. To make it possible to use packages on ASP.NET 4.X web sites, we will add theInstall.ps1
andUninstall.ps1
scripts to platform-specific packages.64
numbers in right places. In sample code, I also added the created packages to metapackages as dependencies, as this seemed reasonable to me.package.ps1
script by using Windows PowerShell requires certain skills, then I renamed it to thepack.ps1
and created a batch file (pack.cmd
) to simplify this procedure.nuget.exe
need to install the Mono. A simple Bash script (pack.sh
) is used to run the packaging process. Ability to create a “symbol” packages is not yet available.There is also an alternative way to run the packaging process, when using only one script (
pack.ps1
) written for the cross-platform PowerShell. Running a script by using this version of PowerShell looks much easier:Everything described in this post is already available as a ready-made solution for creating a NuGet packages. Moreover, it is available in two variants: standard and one-script. I am ready to implement each of these recommendations in the form of pull request.
P.S.: I did not touch the
Microsoft.ChakraCore.SignNuget.proj
andpackages.config
files, because I do not know exactly how they are used. Most likely, they are used to install the MicroBuild.Core and SrcSrv packages, but it is better to check with Microsoft employees.