Troubleshooting

Содержание:

Nuspec

The Windows package manager uses the same infrastructure as NuGet, the Visual Studio package manager by Outercurve Foundation (sponsored by Microsoft). Therefore packages are based on the same principles. One of those is a package description (specification) in format, known as the .

The contains basic information such as the version, license, maintainer, and package dependencies. includes additional optional functionality on top of NuGet’s Nuspec format — the best way to determine currently supported features is to create a test package, and look at the generated nuspec file.

You can indicate the dependency like any other dependency. E.g.:

Logically, the version is based on the lowest compatible version. But if you don’t know and used a lot of sorcery in your package, depend on the version of that you succesfully tested your package on.

See also: NuGet Version Reference

Additional Configuration

Looking for where the apikey is and how it is changed, that is all done through the web.config. The config is pretty well-documented on each of the appSettings key values.

To update the apiKey, it is kept in the web.config, search for that value and update it. If you reach out to the server on https://localhost (it will show you what the apikey is, only locally though).

Performance

To configure for performance, you will want to do the following:

  • Keep the site warm (https://serverfault.com/a/595215/79259):
    • Turn on Application Initialization in Windows Features under Web Server (IIS) → Web Server → Application Development → Application Initialization (you can also try )
    • Application Pool Advanced Settings:
      • General: Start Mode → Always Running
      • Process Model: Idle Time-out (minutes) → 0
      • Recycling: Regular Time Interval (minutes) → 0
    • Under the Site’s Advanced Settings:

Future

We are looking to add support for the package source to automatically handle this aspect — http://blog.nuget.org/20150922/Accelerate-Package-Source.html

Configure Simple Server alongside WSUS admin-site

If you are running Chocolatey Products, namely Simple Server or Central Management, next to a WSUS admin-site, you need to change some settings in the IIS-Configuration for making the Simple Server/Central Management Web interface work correctly again.
This is due to the fact that the WSUS admin-site installation registers two modules in the IIS root configuration, which will be passed down to all other sites running on that IIS instance, including the Simple Server and Central Management sites.

To make things work again, you will need to disable inheritance for these modules in order to remove them from the Chocolatey product site you are working with.

Before making changes to your IIS configuration, read all steps carefully and make sure that you have a backup

You can do this either by PowerShell:

or manual:

  1. Open the IIS Management Console
  2. Click on the server name on the upper left pane
  3. On the right pane double-click on . All available modules will show up
  4. Search for , right-click it and choose
  5. Do the same for
  6. Under on the left pane click on the site for your Chocolatey Simple Server, most likely
  7. Again, search for on the right pane and double-click it
  8. Search for , right-click it and choose
  9. Restart the Chocolatey Simple Server/Central Management site

The website should now be able to handle requests correctly again.

Comparison

How is Chocolatey different than OneGet/PowerShell Package Management?

OneGet is a package manager manager, which means it is not really a package manager at all. Chocolatey will have a provider that plugs right into OneGet. At the current time there is a CTP available, but it is based on 2 year old Chocolatey technology (we’ve had security fixes since then, plus a world of features), so we can’t really recommend it. But if you must use it, make sure your PowerShell execution policy is set correctly and you are in an administrative console. See https://www.hanselman.com/blog/aptget-for-windows-oneget-and-chocolatey-on-windows-10 for more details.

Use ChocolateyGet for now.

How is Chocolatey different than NuGet and/or OpenWrap?

Chocolatey is a machine package manager. Where NuGet/OW are focused on developer library packages, Chocolatey is focused on applications and tools, and not necessarily developer focused.

A typical way of stating the difference is «Developers use NuGet to get 3rd party libraries that they use to build the .NET tools and applications that they release with Chocolatey!»

How is/will Chocolatey be different than apt?

  • Chocolatey does not support the idea of source packages, which are packages that must be built to be used. For someone interested in that, check out https://github.com/Microsoft/vcpkg.
  • Library packages are not completely off the plate, but mostly. How would you link the library up to the application/tool?

Options and Switches

You pass these arguments to an executable that is a shim (e.g. executables in the bin directory of your Chocolatey install, not choco.exe):

  • — shows this help menu and exits without running the target
  • — logging is shown on command line
  • — explicitly tell the shim to wait for target to exit — useful when something is calling a gui and wanting to block — command line programs explicitly have waitforexit already set.
  • — explicitly tell the shim to exit immediately.
  • — explicitly behave as if the target is a GUI application. This is helpful in situations where the package did not have a proper .gui file.
  • — set the working directory to the target path. Useful when programs need to be running from where they are located (usually indicates programs that have issues being run globally).
  • — Do not actually call the target. Useful to see what would happen if you ran the command.

A word about standardization

Anyone who’s used to a package manager on Linux will immediately notice that Chocolatey uses three different commands (cinst, cup, and choco) to carry out operations. That’s a very non-standard way of doing things compared to the Linux-based apt-get or pacman, both of which start every command with and respectively.

To better standardize usage, you can use the command format  to invoke Chocolatey. So instead of typing , you can use the install command:

choco install dosbox

To update, you can use the update command:

choco update dosbox

Even though the standardized approach is favored, Chocolatey’s creator Rob Reynolds says the shorthand commands will remain a part of the project. So feel free to use whichever group of commands you find easier.

Can I use Chocolatey with existing installed software?

Yes, yes you can. Chocolatey works in a similar manner to how you would do things if you downloaded and installed things yourself. Its design and infrastructure is built that way on purpose. It takes the pain of manually doing it yourself away (see previous section).

Now, Chocolatey can take over existing installs and be able to handle uninstalls in most cases. Can is very dependent on packaging and the underlying software installer that is used for the install ( are the context here).

Let me start by saying that testing how a single package won’t give you a warm and fuzzy about how it will work with all packages. Software installers in the wild world of Windows have many completely different ways of going about things, all of which are dependent on those creating the installers, none of which have a consistent standard (except maybe MSI). Welcome to Windows.

Now that we have baselined that — each piece of software out there is a special snowflake, so each package has to be able to account for differences in the installers.

So when a package takes over the existing install, if the registry snapshot doesn’t differ, it won’t be able to automatically uninstall it (if you have autoUninstaller turned on, check ). If there is no that would uninstall the software, choco won’t be able to uninstall it. At some point it will though, choco continues to get better at things. And at some point in the near future it will contain a check to do nothing for an install if a registry key exists (and record that for later uninstall).

The question I need to ask is whether you are worse off by adding choco into the mix? It handles upgrades for you. It brings about some level of consistency and a unifying interface to this madness that is the Windows installer infrastructure.

Установка Chocolatey​

Chocolatey — менеджер пакетов в среде Windows по аналогии с apt-get в Linux, позволяющий установить Node, Python2 и др. Устанавливается менеджер пакетов Chocolatey через консольную оболочку . Для запуска на кнопке вызываем контекстное меню (нажатием правой клавиши мыши) и выбираем пункт .

  • En
  • Ru

Альтернативный вариант

Рядом с меню кнопка -> вводим и через контекстное меню выбираем .

Откроется оболочка в консольном режиме. Для проверки возможности запуска скриптов от сторонних производителей вводим команду:

Скопировать

По умолчанию использование сторонних скриптов заблокировано (Restricted). Разрешим выполнение сторонних скриптов командой:

Скопировать

Выполнение команды потребует подтверждения, отвечаем символом Y (Yes).

Проверим разблокировку запуска скриптов из консоли предыдущей командой:

Скопировать

При успешном выполнении ответом будет .

Теперь можно использовать сторонние скрипты. Установим менеджер пакетов следующей командой:

Скопировать

После окончания загрузки можно проверить корректность установки данного пакета. Вводим в команду:

Скопировать

или точнее

Скопировать

На время написание данной статьи версия .

FAQ

How do I take advantage of this feature?

This works with all versions of Chocolatey. Just use packages and when those packages have exe files, those are automatically shimmed so they are on the PATH.

How does it work?

Chocolatey uses a tool called ShimGen that inspects an executable and creates a small binary, known as a «shim», that simply calls the executable. Then it places that shim in the . It creates the shim by generating it at runtime based on the actual binary’s information.

How is this better than symlinks?

When you symlink a file on Windows, you must symlink all of its dependencies like dlls and config files. If you put that all into the folder to take advantage of being on the PATH, you can quickly see that you will get into a form of «DLL hell» when other executables depend on different versions of the same DLL. You would also need to symlink folders and files for things like plugins, extensions, skins, and other things that are in the original directory. If you are trying to create a symlink to not add more locations to your PATH environment variable, then this particular shortcoming defeats that purpose entirely.

Shimming by design does not run into this issue.

Does it require admin rights?

No, and this is another thing that sets it apart from symlinks. To create symlinks on Windows, you need to have , which is one of the privileges granted to Administrators.

Why not simple batch redirection?

We tried using batch («.bat») files, and it mostly works, but when applications calling other applications expect the file name to be «.exe», a file named «.bat» doesn’t work. Batch files also don’t work in all shells, and shims do.

Have you thought about shimming in more places?

Yes, but we have not decided whether shimming Program Files is a good idea yet or not. Packages can explicitly enforce shims with Install-BinFile.

I need to shim a non-exe file.

If you are creating a package and you need to shim a file that doesn’t end in .exe (like a .bat file), you should look at Install-BinFile.

I need to exclude a file from shimming.

If you are creating a package and you want to skip creation of a shim for a particular file, you can create a «*.ignore» file.

Set an empty file next to the executable (or where it will be downloaded/unpacked to), sharing the same name with the executable and appending «.ignore». For example, if your file is named «», you need a file named «» (pay attention to case — «» may not work with all versions of Chocolatey).

I have architecture specific binaries to shim

If you are creating a package where you have two binaries (or sets of binaries) to shim depending on architecture, one for x86 and one for x64, you can put them in sub-folders and the correct one(s) will be shimmed.

Specifically, include 32-bit binaries in «» and 64-bit binaries in «».

This may eliminate the need to include a «» in the package to create «» files for the other architecture.

How can I ensure a GUI shim?

Chocolatey 0.9.10+ will automatically detect GUI applications and adjust the shim accordingly. The detection may not always be accurate, and older versions of Chocolatey don’t handle this, so it’s best to create a «*.gui» file to direct the shim creation to be for a GUI application.

If you are creating a package and want the shim to exit immediately after calling the application, create an empty «*.gui» file next to where the exe file is (or where it will be downloaded/unpacked to), sharing the same name with the executable and appending «.gui». For example, if your file is named «», you need a file named «» (pay attention to case — «» may not work with all versions of Chocolatey).

An executable requires being run from the folder where it actually is.

Call the shim with . There are badly behaved applications that don’t run well from anywhere, and they require some extra help so they will run correctly.

But what about security?

Chocolatey is convenient, but there’s no way around the fact it’s not an ideal choice if you’re concerned about security for your PC right now. Installing programs with Chocolatey requires that you trust the package creator.

You could monitor Chocolatey as it installs your programs to see which sites the downloads are coming from, but that defeats the convenience of using Chocolatey as an automated process.

The implicit trust model probably means that pulling from the Chocolatey community feed wouldn’t be the best choice for large enterprises or even smaller companies. That said, Chocolatey can be tuned to rely on a private feed controlled by the company where all packages are vetted by the IT department.

While security is not ideal right now, Reynolds says there are some big changes in the works for future versions of Chocolatey. Over the next year, trusted community members will begin moderating the stable feed and all packages will be reviewed before being added. Approved packages will include cryptographic signing by the moderator who approved it.  

Future versions of Chocolatey will include a scanning algorithm to detect packages with malicious intent. Users will also be able to control who they trust by accepting or denying packages based on public key signatures, just like package managers in Linux. 

Summary

tl;dr — Chocolatey.Server is not recommended for most organizational use cases. There are more robust options out there. However if you have a very simple use case or are conducting a POC, Chocolatey.Server may be good enough for your needs. If you don’t find it robust enough, our recommendation is to look to something more robust like Artifactory, Nexus, or ProGet (two of which are also free to use).

The Chocolatey.Server package contains the binaries for a fully ready to go Chocolatey NuGet Server where you can serve packages over HTTP using a NuGet-compatible v2 OData Atom Feed. Chocolatey Simple Server (aka Chocolatey Server aka chocolatey.server) is an implementation of a NuGet.Server compiled and ready to go.

Creating Packages

Install-ChocolateyPath doesn’t seem to work.

I added , but after installing when I try to run the installed application I get «not recognized as the name of a cmdlet, function, script file, or operable program.» Please see .

ERROR: Cannot bind parameter because parameter ‘fileType’ is specified more than once.

This error is seen sometimes on versions of Chocolatey older than 0.10.6. The problem is likely you have the following in your packaging:

didn’t have both a parameter and a parameter. PowerShell has a «feature» where it does partial matching of parameters. When you splat the parameters in, it tries to apply both and to and throws the above error.

Typically, when you are installing locally, you likely want to use anyway.

Reference: https://groups.google.com/d/msgid/chocolatey/40736df7-7f3f-4be7-929d-1606be0e3a62%40googlegroups.com (you will need to join the group to see the message)

ERROR: This package does not support 64 bit architecture.

This message is from https://github.com/chocolatey/choco/issues/527 — it is when the url value chosen is empty. This is common when you are creating a package and you forget to use splatting, instead passing the variable in as the first positional parameter to a function.

This means you have set up your arguments for a function and then called something like instead of . Note is for splatting, taking the values in the hash variable and using the key/values to pass those each as parameters to a function, where just passes the entire hash as the first parameter of the function.

References:

  • https://github.com/majkinetor/au/issues/70
  • https://groups.google.com/d/msgid/chocolatey/5c544e16-e1b2-4249-bad6-4591017df81b%40googlegroups.com (you will need to join the group to see the message)
  • https://github.com/chocolatey-community/chocolatey-packages/issues/439 (separate issue)

This is similar to the above, the error is the same. In most cases it stems from setting up your package parameters for but calling instead. Learn the differences at the PowerShell function reference.

Reference: https://groups.google.com/d/msgid/chocolatey/d11d8eb2-74b3-4c2c-b0bb-d1a1ed3df389%40googlegroups.com (you will need to join the group to see the message)

ERROR: A null key is not allowed in a hash literal.

Typically you see this if you accidentally use a variable name on the left side of a hash:

Note the use of on the left side, which should be just . Once you fix that, things should start working appropriately.

Reference

General

What is Chocolatey?

Chocolatey is kind of like apt-get, but for Windows (with Windows comes limitations). It is a machine level package manager that is built on top of nuget command line and the nuget infrastructure.
More behind the name

«Okay, machine package manager, that’s nice. What does that mean though?» It means you can simply install software with a few keystrokes and go get coffee while your co-workers are downloading and running an install manually (and I do mean something like an MSI).

How about updates? Wouldn’t it be nice to update nearly everything on your machine with a few simple keystrokes? We think so, too. Chocolatey does that.

Can I use Chocolatey at my organization?

Absolutely! The licensing is very business friendly (plus we have paid options to better help organizations — hint, hint). We typically recommend organizations depending Chocolatey look to managing their own packaging as opposed to using the Community Package Repository (https://community.chocolatey.org/packages) — packages there are not 100% reliable due to distribution rights with publicly available packages (which causes a major failure point). See the next question for details.

Are you redistributing software?

No. Packages on Chocolatey’s community repository (https://community.chocolatey.org/packages) are publicly available and as such they are subject to software distribution rights. With those packages the following applies:

To put it another way, Microsoft would be quite upset if the Office 365 packages on the community repository actually contained the Office 365 binaries. This is not something organizations would be subject to when hosting their own internal package.

When you host internal packages, those packages can embed software and/or point to internal shares. You are not subject to software distribution rights, thus you can create packages that are more reliable, offline, and secure. See for more details.

For more information on organizational cautions about the community package repository, see the community repository disclaimer.

Where does Chocolatey install by default?

As of version 0.9.8.24, binaries, libraries and Chocolatey components install in (environment variable %ProgramData%) by default. This reduces the attack surface on a local installation of Chocolatey and limits who can make changes to the directory.

What kind of package types does Chocolatey support?

  • Binary Packages – Installable/portable applications – This is 98% of the Chocolatey packages – most are pointers to the real deal native installers and/or zipped software.
  • PowerShell Command Packages – Packages that have the suffix .powershell will install PowerShell scripts as commands for you to call from anywhere.
  • Development Packages – Packages that have the suffix .dev. For instance dropkick.dev.
  • Roadmap – Virtual Packages – Packages that are like a category, and you just want one package from that category. Read more …

Common Errors and Resolutions

When you are attempting to install the Simple Server, you may run into some errors depending on your configuration. Here are some common ones we’ve seen that you may get when you browse to the the site.

Error 404 on Push

If you can do everything except push packages, it is likely your application pool is set to Classic mode and can’t find directories. It needs to be «Integrated». Please change that to Integrated and then recycle the application pool. That should resolve the issue of pushing packages. Reference: https://stackoverflow.com/a/37702935/18475.

This can mean a couple of things:

  • You missed ensuring the website is using an app pool that is at least .NET 4.0. Check the app pool that your site is using, then ensure that app pool has enabled and the managed runtime version is (or some version of 4).
  • You have made a change to the xml file and it is not valid xml. This typically happens if you put an xml escape character into the password (). To do that you would need to set CData around the value or use a different password. It could also happen if you accidentallly change the xml and it is no longer valid.
  • You are attempting to set up Chocolatey Server next to WSUS Administration website. See for instructions on how to make Chocolatey Simple Server work alongside the WSUS admin-site.

Other error

Turn on customErrors under system.web — — see this guide to set it — https://stackify.com/web-config-customerrors-asp-net/

Then browse to the site to see if you can gather any more information.

If so, and you are a commercial edition customer, please open a support ticket. If you are using open source Chocolatey, please open a ticket at https://github.com/chocolatey-community/simple-server/issues.

Chocolatey. Что это такое? Как установить и как им пользоваться?

Как обычно вы устанавливаете программу в Windows? Вы находите нужную программу в интернете, скачиваете её с сайта (в лучшем случае с официального) и запускаете установку. Не редко вместе с программой устанавливаются не нужные вам дополнительные программы. Кстати, на сайте есть статья про то как защититься от таких установщиков.В Linux системах существует альтернативный подход к установке программ. Там используются специальные менеджеры пакетов, которые почти избавляют вас от необходимости скачивания программ из интернета. К тому же можно подключать несколько различных репозиториев.Chocolatey — это репозиторий с программами для windows 7 и выше. Он предоставляет те же преимущества, что и менеджеры пакетов в Linux. На данный момент этот репозиторий насчитывает уже более 8000 популярных программ.

Как установить?

  • Windows 7+ / Windows Server 2003+
  • PowerShell v2 +
  • .NET Framework 4+ (при установке будет предпринята попытка установить .NET 4.0, если он у вас не установлен)

Установить его можно выполнив специальную команду. Команду нужно выполнять либо в командной строке CMD.exe либо в PowerShell.exe. Оба должны быть запущены с правами администратора. Вот сами команды:

  1. Для CMD.exe
  2. Для PowerShell.exe

После установки, Chocolatey можно обновить точно так же, как любой другой пакет, который был установлен с помощью Chocolatey. Просто используйте команду для обновления до последней стабильной версии Chocolatey:choco upgrade chocolatey

Как пользоваться менеджером пакетов Chocolatey

А как узнать какая команда какую программу устанавливает? Посмотреть команды для каждой программы можно в самом хранилище пакетов https://chocolatey.org/packages.

Обновление и удаление программ установленных с помощью репозитория

Обновить программу установленную с помощью Chocolatey очень легко. Для этого в PowerShell можно выполнить команды:Для обновления всех программ — choco upgrade allДля обновления только браузера Chrome — choco ugprade googlechromeДля того, чтобы просто проверить, есть ли обновления для установленных программ, без самого обновления, можно воспользоваться командой choco outdatedДля удаления программы выполните команду choco uninstall «имя программы», например для Google Chrome это будет команда choco uninstall googlechrome

Другие полезные команды

Есть ещё команды, которые возможно будут вам полезны. Команда choco list -lo выводит список всех программ установленных в систему из менеджера пакетов.Поиск программ в репозитории можно произвести командой choco search «имя программы». Если нужная программа есть в хранилище, то мы получим его имя и уже потом легко сможем его установить.

Графический интерфейс Chocolatey

Для тех пользователей, которые не привыкли использовать командную строку есть графический интерфейс Chocolatey. Для его установки, вам, все же придется сначала установить стандартный версию, а потом с помощью команды choco install chocolateygui установить графический интерфейс.Если увидите строчку Do you want to run the script?(es/ll — yes to all/o/rint):, то наберите букву «Y» и снова нажмите «Enter».Запустить графический интерфейс можно с помощью ярлыка «Chocolatey GUI» в меню Пуск. У Chocolatey GUI есть некоторые ограничения в отличие от консольной версии, но с каждой версией в него добавляют новые возможности. На данный момент он умеет:

  • Отображать список программ, установленных на локальном компьютере из репозитория
  • Устанавливать / удалять / обновлять / закреплять / откреплять пакеты Chocolatey
  • Добавлять / удалять источники
  • Включать / отключать функции Chocolatey
  • Изменять значения конфигурации Chocolatey
  • Изменять отображение на Список и мозаичный вид установленных / доступных пакетов

В графическом интерфейсе слева в боковом меню, нажав на кнопку Chocolatey можно просмотреть каталог программ. Здесь можно искать программы и установить нужную одним кликом, не используя консольную оболочку PowerShell. А выбрав вкладку Этот ПК слева вы увидите все программы, которые были установлены в систему с помощью Пользуйтесь этим инструментом друзья. Он достоин этого.

You can’t live on Chocolatey alone

Although Chocolatey sounds pretty tasty, it isn’t for every program out there. You can’t use Chocolatey for a program stuck behind a paywall, for instance. However, any programs that are free to download and ask for a purchase or license key are fair game.

Unless you want to start seeking out new sources or creating your own packages, you are restricted to what’s in the community feed.

The current feed is pretty large, with more than 2,000 unique packages and more than 8,000 total at time of writing. It includes a variety of programs including all the major third-party web browsers, uTorrent, Vuze, Notepad++, Sublime Text (versions 2 and 3), VLC, Office 365 Home Premium, CCleaner, GIMP, IrfanView, Skype, and many others.  

Chocolatey may not be for every Windows user, but anyone who wants to get their hands a little dirty on the command line will find a very useful tool with this package manager for Windows.

Rules to be observed before publishing packages

There are a few rules that you have to follow before pushing packages to chocolatey.org:

  1. Don’t package illegal software. Packages of software that is illegal in most countries in the world are prohibited to publish on Chocolatey.org. This applies in particular to software that violates the copyright, pirated software and activation cracks. Remember that this also affects software that is especially designed to accomplish software piracy.
  2. Do not include software in a package that you don’t have the right to distribute. Please see for more information. Any package found not in compliance with this will be removed immediately. Instead you can download binaries from official distribution locations at runtime.
  3. Packaging commercial or trial software? Clearly state this in the package description. Does it require an activation key? Is there a trial period if you don’t have a key? How long is this trial period?
  4. Only post publicly relevant packages. You should consider whether this package is useful for others. If that is not the case, it shouldn’t be published on Chocolatey.org. Reasons for that can be if the package would require a very customized configuration. You can host your personal packages on MyGet and still be able to install them with Chocolatey using the parameter.
  5. Do not publish junk or malware packages.
  6. Don’t package software containing malware. Packages of software that comes with bundled adware, spyware or other unrelated software that installs even in silent mode, are not allowed. But if you can figure out how to install the desired software without this unrelated software, it is allowed to publish the package. That can be accomplished for example with additional command line switches or by adding specific values to the registry. Examples of packages which make use of this are PDFCreator and CCleaner.
  7. Don’t package software that is already packaged. Use the search function in the community.chocolatey.org gallery and look if there is already a package for the desired software. If you would like to improve the already existing package or if you have suggestions, just contact the package maintainer or open a pull request at the maintainer’s package repository.
  8. Don’t include other required software if there’s a package of it. If a package requires other software of which there is already a package, the already existing package should be used as instead.
  9. Split dependencies into multiple packages. Try to split up packages as much as possible. If for example a program comes with additional modules/installers that are optional, make different packages for them instead of including all the things into one package. This idea is already widely applied for Linux packages, because it leads to a more lightweight system and reduces potential issues and conflicts.
  10. Use a simple intuitive lowercase name for the package. See the for details. (If you are a reviewer/moderator, this is considered a guideline).

Is your package unqualified for the Chocolatey feed, but you like to be able to install it through Chocolatey? One alternative would be to host your package on MyGet. See Hosting Chocolatey Packages on MyGet.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector