Posts

Showing posts from November, 2017

NuGet scripting in VS 2017

Image
Spanish version / Versión en Español If any of you ever published a .NET project as a NuGet package and needed some custom scripting to run when the package was installed, this used to be possible using the install.ps1/uninstall.ps1 mechanism . However, support for this was dropped in Visual Studio 2017, which bundles NuGet 4.x. The Init.ps1 script is still supported, but it runs every time the solution is opened, which might not be appropiate for most use cases. Another problem with the new VS 2017 NuGet way of doing things is that the .nuspec file, which was used to define metadata and files to package, is now gone; metadata is now handled via the project's properties, in the new Packaging section: In turn, this information is saved in the .csproj project file: The problem with this is, how to define which files to package inside the resulting .nupkg file using only .csproj? There is an alternate approach to NuGet scripting which involves embedding MSBuild

Correr scripts en NuGet en VS 2017

Image
Versión en inglés / English version Si alguna vez publicaron un proyecto .NET como paquete NuGet y necesitaron ejecutar scripting personalizado al instalar el paquete, eso era posible antes usando el mecanismo install.ps1/uninstall.ps1 . Sin embargo, el soporte para esto fue retirado en Visual Studio 2017, el cual incluye NuGet 4.x. El script Init.ps1 sigue siendo soportado, pero el mismo es invocado cada vez que se abre la solución, lo cual puede no ser apropiado para la mayoría de los casos de uso. Otro problema con el nuevo manejo de NuGet en Visual Studio 2017 es que el archivo .nuspec, que se usaba para definir metadata del paquete y archivos extra a empaquetar, ya no está; la metadata en VS 2017 ahora se maneja a través de las propiedades del proyecto, en su nueva sección Packaging: Una vez ingresada en las propiedades del proyecto, esta información es almacenada en el archivo .csproj: El problema con este nuevo enfoque es, ¿cómo definir qué archivos empaqueta