mirror of
https://github.com/quamotion/dotnet-packaging.git
synced 2026-02-15 13:46:36 +00:00
Ability to set package name #74
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @leoshusar on GitHub (Apr 5, 2020).
Hello, I am currently trying to package my app for linux and I have problems with naming.
My assembly name was with underscore -> debian does not allow underscores in names.
I changed it to dash -> I was having problems with building.
Lastly I changed my assembly name and namespace to AppName (as I found that this is the right naming convention) but linux does not allow uppercase letters in names too.
I would like to specify my own package name (name like app-name) or at least convert it to lowercase naturally (appname).
Or did I miss something and this ability is already there?
@joshd-7 commented on GitHub (Apr 9, 2020):
I just ran into this as well. After doing a fair amount of digging in the code and testing there's a few settings you can make in your .csproj
To change the debian package name: (Debian naming standard in example, underscores and periods are ok in this one)
<PackageName>debian-package-name_0.1.0-1_amd64</PackageName>Output ex: debian-package-name_0.1.0-1_amd64.deb
To change the "Package" variable in the control file of the debian package: (Important that this doesn't have underscores, periods or upper case)
<PackagePrefix>project-name</PackagePrefix>Here's how you can verify the changes if you need.
Unpack the debian in a folder with
dpkg -e debian-package-name_0.1.0-1_amd64.debOpen the control file and verify the value assigned is correct
Package=project-nameHere's some of the other properties I set within the .csproj to help populate the other Debian files.
<PropertyGroup><DebPackageArchitecture>amd64</DebPackageArchitecture><PackagePrefix>project-name</PackagePrefix><PackageName>debian-package-name_0.1.0-1_amd64</PackageName><Version>0.1.0-1</Version><Authors></Authors><Company>CompanyName</Company><Product>ProductName</Product></PropertyGroup>There might be better ways of doing this, but this is what I got to work for me. I was able to leave my project and assembly name pascal case with periods in it.
@leoshusar commented on GitHub (Apr 9, 2020):
Thank you!
I've made some tweaks to it, you might find it useful:
What it does is it generates
PackagePrefixfromAssemblyName- adds a dash before every capital letter and makes it lowercase.Then it selects
DebPackageArchitectureusing your RuntimeIdentifier (-r switch).Finally it makes
PackageNameasPackagePrefix_Version_DebPackageArchitecture.Finally all you have to do is for example
dotnet deb -c Release -r linux-x64and it will generate file namedmy-awesome-project_0.1.0-1_amd64.deb.There will surely also be a way to add this to a separate file and then just write some single line Include in your .csproj, but this is enough for me now.
EDIT: the only problem now is that installed binary file is still PascalCase.
EDIT2: Solved! This targets renames binary file in OUTDIR (probably not necessary), then it renames binary file in OUTDIR\publish (this one is important) and finally it sets AppHost name and this is the name of the symlink in /usr/local/bin.
EDIT3: If you put everything into
Directory.Build.targetsfile, it will automatically pick it up and you don't have to edit your .csproj file. All you need is then copy that file into your another project and you're ready to go.@joshd-7 commented on GitHub (Apr 10, 2020):
Great additions! That was the next thing I was going to look into for improving it. Thanks a bunch!