У меня есть консольное приложение dot net core, которое я хочу упаковать в файл .exe и раздать коллегам.
Поскольку все пользователи продукта используют Windows 10, я создаю проект, используя
dotnet build -r win10-x64
Это здорово тем, что дает небольшой пакет развертывания. Теперь, когда я представил сторонние библиотеки (через nuget), у меня возникла проблема, заключающаяся в том, что они не включены в выходные данные сборки.
Есть ли способ создать проект ядра точки сети в виде .exe, включая сторонние библиотеки, но не все библиотеки точки сети?
Следуя примеру @turobo снизу, я получил следующее:
dotnet publish -r win10-x64 -c Release --self-contained false
Вы почти у цели. Вам нужно использовать команду «dotnet publish» для создания пакета dotnet. В dotnet core команда сборки не предназначена для создания распространяемого пакета.
Выдержка из ссылка на сборку dotnet:
If the project has third-party dependencies, such as libraries from NuGet, they're resolved from the NuGet cache and aren't available with the project's built output. With that in mind, the product of dotnet build isn't ready to be transferred to another machine to run. This is in contrast to the behavior of the .NET Framework in which building an executable project (an application) produces output that's runnable on any machine where the .NET Framework is installed. To have a similar experience with .NET Core, you need to use the dotnet publish command. For more information, see .NET Core Application Deployment.
То, что вы ищете, это исполняемые файлы, зависящие от платформы (FDE). Выдержка из здесь:
Framework-dependent executables. Produces an executable that runs on a target platform. Similar to FDDs, framework-dependent executables (FDE) are platform-specific and aren't self-contained. These deployments still rely on the presence of a shared system-wide version of .NET Core to run. Unlike an SCD, your app only contains your code and any third-party dependencies that are outside of the .NET Core libraries. FDEs produce an executable that runs on the target platform.
Это должно работать:
dotnet publish -r win10-x64
Да команде публикации. В итоге я использовал команду в соответствии с моим отредактированным вопросом выше. Спасибо за указатели.