In my package, I have a module and a plugin. When I uninstall a package from the Extension Manager, the plugin gets uninstalled but the module remains there. Also the package entry gets removed from the Extension Manager. Then I have to manually uninstall the module. I get the following messages:
Warning
Attempting to uninstall unknown extension from package.
This extension may have already been removed earlier.
Message
Uninstalling package was successful.
How do I ensure the module gets uninstalled when I uninstall the package?
UPDATE:
My package manifest:
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="3.0">
<name>RR Test One Package</name>
<author>John Doe</author>
<creationDate>November 2013</creationDate>
<packagename>rr_test_one_package</packagename>
<version>1.0</version>
<packager>John Doe</packager>
<description>Lorem ipsum dolor sit amet.</description>
<files folder="packages">
<file type="module" id="rr_test_one" client="site">mod_rr_test_one.zip</file>
<file type="plugin" id="rr_test_one" group="content">plg_content_rr_test_one.zip</file>
</files>
</extension>
I have script.php inside the plugin and module folders to make some updates to the database entries. The plugin uninstalls without the uninstall function when I uninstall the package. It's just not uninstalling the module. Do I need to have another script.php in the packages folder along with the package manifest and have the uninstall function in the script.php?
It was the id in the <file> tag of the module type that was giving out the warning. I added mod_ in the id. Below is what I did and this resolved the issue.
<files folder="packages">
<file type="module" id="mod_rr_test_one" client="site">mod_rr_test_one.zip</file>
<file type="plugin" id="rr_test_one" group="content">plg_content_rr_test_one.zip</file>
</files>
Related
This question might be a little outdated, but does 'init.ps1' scripts still works when installing a nupkg?
I was trying to use 'install.ps1' and 'uninstall.ps1', but after a little bit of research I've seen that those files stopped working with Visual Studio 2017 (which is the version of Visual I'm currently using), but I have not found any recent information about 'init.ps1' (being the most recent from 2017 or 2018).
My script is working correctly when executed by itself but seems like it's not getting called on the package install.
In the case that 'init.ps1' still works here's my '.nuspec' file, am I doing something wrong?:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>NugetTry</id>
<version>0.0.142</version>
<title>NugetTry</title>
<authors>rwpk9</authors>
<description>Description</description>
<copyright>Copyright © 2023</copyright>
<dependencies>
<group targetFramework=".NETFramework4.7.2">
<dependency id="EntityFramework" version="6.4.4" />
<dependency id="Microsoft.AspNet.Mvc.es" version="5.2.9" />
<dependency id="Newtonsoft.Json" version="13.0.2" />
</group>
</dependencies>
</metadata>
<files xmlns="">
<file src="init.ps1" target="." />
</files>
<powershell xmlns="">
<scripts>
<base><![CDATA[init.ps1]]></base>
</scripts>
</powershell>
</package>
My 'init.ps1' is at the same path as the '.nuspec'.
The init.ps1 file needs to be in a tools/ directory, not the package root. So, the zip file's central directory record has a path of tools/init.ps1
I think this no longer works.
I already put the init.ps1 to the tools directory and then configured the .nuspec, after that, package the package.
But if I install the package at the first time in the solution, I didn't see my powershell script run.
From the Nuget Product Team member:
https://github.com/NuGet/Home/issues/4318#issuecomment-343255043
powershel script is deprecated for package reference, we don't
recommend people to use script in their packages.
I think this is deprecated.
We have some executables which we need to create our setups. So we have packed
the external dependencies which are some .exe files into a nuget package. But on NuGet restore they are added to project root.
How can we achieve this ?
Have searched around but haven't found any solution so far.
Since we use nuspec file, this is what i have it as:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>VCRedistributable</id>
<version>$version$</version>
<title>VCRedistributable</title>
<authors>--</authors>
<owners>--</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>InstallVCRedistributable assemblies</description>
<contentFiles>
<files include="**" exclude="**" buildAction="None" copyToOutput="false"
/>
</contentFiles>
</metadata>
<files>
<file src="VC\x86\*.*" target="content\x86" />
<file src="VC\x64\*.*" target="content\x64" />
</files>
Any ideas ?
Prevent content files to be added on Nuget restore
You should target to the tools folder instead of content folder.
So, your .nupsec file should be:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>VCRedistributable</id>
<version>$version$</version>
<title>VCRedistributable</title>
<authors>--</authors>
<owners>--</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>InstallVCRedistributable assemblies</description>
</metadata>
<files>
<file src="VC\x86\*.*" target="tools\x86" />
<file src="VC\x64\*.*" target="tools\x64" />
</files>
</package>
That because the content directory is a convention-based working directory, which contents are copied to the project root:
Convention-based working directory:
Besides, if you nuget package just include external some .exe files, you do not have to add the contentFiles label, this label is used for the content file for packagereference.
<contentFiles>
<files include="**" exclude="**" buildAction="None" copyToOutput="false"
/>
</contentFiles>
If you are interested in, you can check this document for some more details.
Update:
Is it good convention to create our own folder structure other than
NuGet defined since based on the tools folder description from above
it seems they will be accessible via Package Manager Console.
Of course, you can use your own folder structure other than NuGet defined. But you need to notice that there will be a limit to do this. You can NOT just include your own folder structure, you need also need add a NuGet defined folder structure in your .nuspec, otherwise, nuget will install failed with the error like:
Could not install package 'MyCustomPackage 1.0.0'. You are trying to
install this package into a project that targets
'.NETFramework,Version=v4.6.1', but the package does not contain any
assembly references or content files that are compatible with that
framework.
Because nuget did not detect that you added assembly references or content files to the project.
Hope this helps.
My organization wants to segregate all the development machines on a network without internet access.
I found this article that gives that gives some nuget host product, so that the packages are available offline.
My problem is that I can't find a way to manage the package update, because the machines that have and internet access won't have Visual studio installed.
I was looking if there is a tool that reads a folder where all nupkg files are stored and check if a newer version is available and downloads it, or otherwise reads a manually created packages.config file checks for newer version and download them on a folder.
Does anyone have an idea how to manage nuget packages in this way? I spent the last week trying to find a way but I had no look.
Does anyone have an idea how to manage nuget packages in this way?
According to the NuGet CLI reference:
The update command also updates assembly references in the project
file, provided those references already exist.
So when we use NuGet.exe update the package, we are not only need the packages.config but also need the solution/project, otherwise, you will get the error:
"Unable to locate project file for 'D:\NuGetServer\packages.config'
You can copy a simple project from the machine, which have Visual Studio installed, then use below command line to update the nuget package in the package.config file:
nuget update "YourProjectPath\packages.config"
But NuGet will update the packages into the packages folder under the solution folder by default, so we need change the packages folder to the folder where all nupkg files are stored before update packages.
Detail steps:
Download the nuget.exe from nuget.org, set it to your local machines.
Create a NuGet folder under the path %appdata%, add the NuGet.Config file and change the packages folder by repositoryPath, just set it "D:\NuGetServer":
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<config>
<add key="repositoryPath" value="D:\NuGetServer" />
</config>
</configuration>
Copy a solution from other machine, add the packages in to the package.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="NUnit" version="3.7.0" targetFramework="net45" />
</packages>
Open a CMD file, switch to the path where NuGet is stored in step 1, then use the update command:
You will find packages in the packages.config are updated to the latest version.
I am not very familiar with NuGet and I am wondering if NuGet offers a similar feature to Maven where I can choose to not only install the binary of a dependency but also its source code and documentation.
So, when debugging my solution, I can follow the debugger into code running within a dependency declared and managed with NuGet. This would also have the advantage that when the binary package is updated, NuGet would pull the matching source code.
NuGet supports symbol packages which allow you to debug into a NuGet package's source code in Visual Studio.
However this only works if the creator of the NuGet package published a symbol package.
Yes, it is supported. Here is the relevant documentation:
Creating and Publishing a Symbol Package
Here is an example of our NuSpec-File. It ist so generic, that it's literally the same for every package:
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<title>$title$</title>
<tags>$tags$</tags>
<owners>$owners$</owners>
<authors>$authors$</authors>
<version>$version$</version>
<description>$description$</description>
<copyright>$copyright$</copyright>
<requireLicenseAcceptance>$requireLicenseAcceptance$</requireLicenseAcceptance>
<releaseNotes>$releaseNotes$</releaseNotes>
</metadata>
<files>
<file src="readme.txt" />
<file src="\bin\Release\*.pdb" target="lib\net45" />
<file src="**\*.cs" target="src" exclude="obj\**"/>
<file src="**\*.vb" target="src" exclude="obj\**"/>
</files>
</package>
We also use the Visual Studio Extension "NuGet Deploy", you can find it in the VS Gallery.
If you still cannot Step into your package source code, make sure you loaded the symbols. Check it during dubugging in the Pane "DEBUG->Windows->Modules"
I have created custom component and a route plugin for Joomla 1.5 to to provide SEO URLs for my component and also articles and categories which are not menu tied. Now I have to install my component and route plugin separately. Is there a way to install both in one package please?
Thank you in advance! Vojtech
There is a easier method.
What is a package?
A package is a extension that is used to install multiple extensions in one go.
How do I create a package?
A package extension is created by zipping all zip files of the extensions together with a xml manifest file. For example if you have a package composed by:
component helloworld
module helloworld
library helloworld
system plugin helloworld
template helloworld
The package should have the following tree in your zipfile:
-- pkg_helloworld.xml
-- packages <dir>
|-- com_helloworld.zip
|-- mod_helloworld.zip
|-- lib_helloworld.zip
|-- plg_sys_helloworld.zip
|-- tpl_helloworld.zip
The pkg_helloworld.xml could have the following contents:
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="1.6">
<name>Hello World Package</name>
<author>Hello World Package Team</author>
<creationDate>May 2012</creationDate>
<packagename>helloworld</packagename>
<version>1.0.0</version>
<url>http://www.yoururl.com/</url>
<packager>Hello World Package Team</packager>
<packagerurl>http://www.yoururl.com/</packagerurl>
<description>Example package to combine multiple extensions</description>
<update>http://www.updateurl.com/update</update>
<files folder="packages">
<file type="component" id="helloworld" >com_helloworld.zip</file>
<file type="module" id="helloworld" client="site">mod_helloworld.zip</file>
<file type="library" id="helloworld">lib_helloworld.zip</file>
<file type="plugin" id="helloworld" group="system">plg_sys_helloworld.zip</file>
<file type="template" id="helloworld" client="site">tpl_helloworld.zip</file>
</files>
</extension>
When any extension installed Joomla triggers an event 'com_yourcomponent_install()' to your install file, which you have mentioned in xml file.
write a function com_yourcomponent_install in which get the path of plugin folder and install it
$installer = new JInstaller();
// Install the packages
$installer->install($pluginPath);
For example
in you xml file install.mycomponent.php
and in install.mycomponent.php there should be a function com_mycomponent_install()
this function will contain the code as
$installer = new JInstaller();
// Install the packages
$installer->install($pluginPath);