Running powershell scripts during nuget package installation and removal

来源:https://devblogs.microsoft.com/nuget/NuGet-3-What-and-Why/

Since Visual Studio 2015 was released in July, developers have started using a new version of NuGet, NuGet 3 We decided to introduce a number of significant changes based on feedback from the community. With any major version change, some things break… and usually for a good reason. We have bugs and issues that we are addressing and want to share what the plan was for versions 3.x and what the plan is for the future.

The NuGet 2.x code base proved to be tightly coupling user interface and protocol. NuGet 3 included a major rewrite of the code base to allow for supporting the new V3 nuget server Protocol.

User Interface Changes

The most noticeable change to the NuGet client is the updated user interface. This is also the feature that has brought the most feedback. What was changed? The only thing that changed was everything… this is a complete rewrite of the Visual Studio interface for NuGet, bringing new features and dropping other features.

Let’s review some of the items that were changed and what user feedback drove the change:

  • The NuGet window was changed to a docked window to allow continued work on other tasks in Visual Studio while packages are being installed
  • Package version selector was introduced to allow more control over which packages to install and manage, allowing explicit control of package versions in projects. This also helps to prevent inadvertent breaks with new major package versions.

  • Visibility controls were introduced for the preview window because developers didn’t want to be distracted by this information and wanted to continue working without interruption.

  • The file conflict action combobox was added to allow control over how project content should be handled when a content package is installed or updated. Content packages provide a dual purpose of scaffolding initial content or bringing libraries that were not intended to be changed. With this configuration option, you can control what action NuGet should take when installing or updating packages that have existing files in your project that it would like to overwrite.

  • The Update Available indicator is introduced to allow you to work in any filtered view, and still know what packages your project has installed and what may need to be updated.

  • The ‘All Sources’ package source was very hard to use, and the search results were not clear that were presented in the package list. We are making changes to how this functions and is presented, hoping to reintroduce in a future release.

  • Package sources and states were converted to a pair of comboboxes to make it more of a filter action that leads to the search on the right side of the screen, similar to how many websites provide search capabilities. This is confusing as the filter controls operate independently of each other.

  • The introduction of an ‘Action’ combobox and button brings a context to the right panel that is not intuitive or discoverable. We hear that when the action combobox is configured with a default value, developers can have difficulty locating alternate actions to take with the package. In the prior user interface, all actions were made available as individual buttons that were easy to locate.

All in all, a number of really important updates for the user interface that added functionality. However, we know that this hindered workflow for some developers. We’re revisiting those decisions and in our next blog post, we’ll discuss what updates are being made.

Update All

The most significant removal from the NuGet user-interface was that ‘Update All” was removed. After hearing from developers who were concerned about breaking changes introduced by a significant number of packages that were updated in their project, this button was not included in the revision. When there are a number of major package changes, developers found the resultant projects difficult to work with due to the number of breaking changes introduced by updated packages.

However, we also hear feedback from developers with more than 100 projects in a solution and are not able to update all of their packages quickly. The ‘Update All’ button is a significant help to these developers, and they experience a significant delay in their workflow when they need to update each package individually. For advanced users who prefer the Powershell console, the Update-Package command still provides ‘Update All’ functionality. We understand that having this in the user-interface is important to many developers and we’re going to bring back the Update All button in our next user-interface update, scheduled for later this Fall.

NuGet v3 Protocol

The NuGet.org service was based on an open WCF data service that allowed for virtually unlimited open-ended queries against a SQL database. The database server was at capacity and we were unable to scale it further without changing the implementation of the service. The new protocol was designed to be more responsive and be able to operate across content-delivery networks without communicating to a central database server. Package detail pages could be stored in a static JSON format on the web server and replicate across the NuGet CDN along with the packages. This would allow for developers to get updates to their packages from local edge nodes without querying the central NuGet.org service which is designed to reduce latency.

In practice over the last 4 months, we have seen a reduction in NuGet.org server resources and a dramatic increase in the utilization of the CDN. From our telemetry, all regions that are using the new NuGet v3 protocol are experiencing a performance improvement. Since the beginning of the year, we see major improvements in server response, even though download traffic has doubled over the last 10 months.

Solution Level Packages

Solution packages were deprecated with this version of NuGet. Why? What do they bring to the feature set? These packages typically did not deliver references for a project, but rather tools that could be shared among several projects. Currently in Visual Studio 2015, these packages can be installed into a project that will be shared in the solution. We now understand that this took some developers by surprise and it prevents solutions from being worked on with both Visual Studio 2013 and 2015. We have a tracking issue opened that addresses this issue, and we are going to schedule it for a future release.

Introducing Project.JSON

For supporting .NET Core that comes with the Universal Windows Platform SDK and ASP.NET 5, we wanted to take several steps to address common questions and concerns that developers had with building applications that referenced NuGet packages. We have introduced the project.json configuration file initially in ASP.NET 5 and Universal Windows Platform projects. This was a chance to start these new project types with a package reference model that could address several significant concerns that developers shared with us:

  • Packages.config file would no longer described the developer’s intent of the packages they wanted to install once dependent packages are added.

  • Installing packages would modify the csproj/vbproj file and prevent it from being easily moved on disk and having a consistent experience in Visual Studio.

  • Support the ability to deliver .NET Core as packages

  • Developers who mixed updating packages from a command-line and from the Visual Studio interface would realize different changes to their project. This made it difficult to configure and maintain continuous integration environments.

Introducing a new package reference model allowed us to address these issues by bringing a new format that more closely aligned with helping a developer with a project, and not modifying the project for them. This model could be introduced for the new Universal Windows Platform projects, and not affect other project types who could continue operating with the existing NuGet packages.config model. Existing projects and project types that operate with packages.config and not project.json are not be subject to the following changes.

To better show a developer’s intent, we created the project.json dependencies feature where developers can directly reference only those packages that they need in their project. Any dependencies are automatically discovered and restored without needing to explicitly document those references in project.json

Project.json for a UWP project and a simulated packages.config showing some of the packages that would be referenced in the same project

The result is that you need to manage less package references and skip dealing with potential circular reference problems.

With Project.JSON managed projects, there is now a packages folder that is shared for all projects that you work with. Packages are downloaded and stored in the <span class="pun">%<span class="pln">userprofile<span class="pun">%<span class="pln">\.nuget\packages</span></span></span></span>folder. This means that if you are working on multiple UWP projects on your workstation, you only have one copy of the EntityFramework package and its dependencies on your machine. All .NET projects will acquire package references from this global shared folder. This also means that when you need to configure a new project, your project will not take time starting so that it can download a fresh copy of EntityFramework.nupkg Instead, it will simply and quickly reference the files you have already downloaded. ASP.NET 5 uses the <span class="pun">%<span class="pln">userprofile<span class="pun">%<span class="pln">\.dnx\packages</span></span></span></span> folder and as that framework nears completion it will use the <span class="pun">%<span class="pln">userprofile<span class="pun">%<span class="pln">\.nuget\packages</span></span></span></span> folder as well.

Powershell script support was modified to no longer execute install and uninstall scripts, but init scripts are still executed. Some of the reasoning for this is the inability to determine which package scripts need to be run when not all packages are directly referenced by a project. Without an explicit install or uninstall for a dependency package, it is impossible to determine when these scripts should be run. We do not believe there is a reliable and repeatable way to execute these scripts in this package reference model. Additionally, as we want to ensure that NuGet provides a repeatable experience on the command-line this forces packages to run without script capabilities. We plan to introduce features to address many of the common tasks that scripts provided.

Additionally, running NuGet outside of Visual Studio at the command-line or on other operating systems cannot execute these Powershell scripts as they relied on Visual Studio automation. Powershell is in NuGet to provide a shim to allow for missing features to run inside of Visual Studio. Moving forward, we plan to introduce these features to provide this functionality. Finally, many of these scripts relied on Visual Studio APIs that could break across versions of Visual Studio.

Configuration file transforms are not typically re-runnable against a project. In the indirect package reference model, NuGet does not know if a configuration transform has been applied to a project reliably. To prevent these transforms from being executed multiple times against the same project, this feature was dropped.

With indirect package references, it is also not clear how to handle the content that may be delivered. When a package is updated, does the content of the indirect references need to be re-copied into the project? What happens to the files and content that a developer was maintaining in their project? Without a reliable answer to these questions, we cut this feature in the short term, and are working to define a proper feature to deliver this functionality. Follow our discussion on GitHub to learn more about the new feature.

Looking Forward

These changes that were introduced means that package authors and package consumers have some new decisions to make and new features to explore. We plan to provide more details on these topics in the weeks ahead. We will discuss the upcoming changes to the user interface, post walk-through tutorials demonstrating how to build new packages that target the Universal Windows Platform and how to update existing packages to make them available to the Universal Windows Platform.

Summary

We hope this gives you some insight into some of the decisions that were made to advance the NuGet product. All of the changes were made with the hopes that they would reduce complexity and prevent any compatibility issues with new frameworks and features required by project systems that NuGet would support. In our next post, we’ll discuss further the NuGet user interface, review some of your feedback, and explore the decisions around the updates that are coming.

Original: https://www.cnblogs.com/micro-chen/p/15137620.html
Author: 特洛伊-Micro
Title: Running powershell scripts during nuget package installation and removal

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/529591/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 数据分析业务知识

    1.电商和消费模型 所谓的电商和消费模型是以商品的交易、零售、购买搭建而起。包括客单价、复购率、回购率、退货率、购物篮大小、进销存等商品概念。 2.市场营销模型 市场营销模型是以传…

    Linux 2023年6月6日
    0127
  • 时钟周期,机器周期和指令周期

    有些概念没有搞清楚,基础不牢呀。 保持更新;https://github.com/yaowenxu posted @2022-02-16 16:18 xuyaowen 阅读(42 …

    Linux 2023年6月14日
    0106
  • algorithm 头文件参考

    定义执行算法的 C++ 标准库容器模板函数。 该 <algorithm></algorithm> 库还使用该 #include <initialize…

    Linux 2023年6月7日
    0120
  • Mysql 5.7开启binlog日志

    Mysql 5.7开启binlog日志 前言 binlog是MySQL的二进制日志,并且是MySQL中最重要的日志。binlog记录了对MySQL数据库执行更改的所有操作,包括对数…

    Linux 2023年6月6日
    0111
  • 2018部分

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    Linux 2023年6月7日
    089
  • 用powershell脚本,检测cpu100%,并触发sqlserver主备切换。

    我为园子设计的脚本大致如下:1慢检测:任务计划每分钟运行。发现cpu高于95%后,触发2。2快检测:每隔5秒钟运行,发现cpu高于95%,连续6次后,触发3。3报警n次。超出5分钟…

    Linux 2023年6月14日
    0114
  • Java基础系列–05_面向对象

    1、概述:(1)面向过程:将问题一步一步的解决的过程(详细步骤),在C语言中所有的代码都是基于过程化的代码。(2)面向对象:面向对象是基于面向过程的编程思想,所有的事情都交由创建出…

    Linux 2023年6月7日
    0113
  • su与su -,sudo 的区别

    “sudo” , “su” , “su – ” 区别; 一、sudo是一种权限管理机制,依赖于/…

    Linux 2023年6月13日
    0133
  • pymysql模块的使用

    pymysql模块的使用 import pymysql 1、连接数据库 conn = pymysql.connect( user=’root’, # The first four …

    Linux 2023年6月14日
    098
  • SpringBoot——自定义Redis缓存Cache

    SpringBoot自带Cache存在问题: 1.生成Key过于简单,容易冲突 默认为cacheNames + ":" + Key2.无法设置过期时间,默认时间…

    Linux 2023年5月28日
    0102
  • 操作系统实战45讲笔记 -06 程序中的地址如何转换

    每个应用程序的虚拟地址空间都是相同且独立的。 虚拟地址是由链接器产生的。开发软件经过编译步骤后,就需要链接成可执行文件才可以运行,而链接器的主要工作就是把多个代码模块组装在一起,并…

    Linux 2023年6月7日
    0125
  • Docker centos7,宝塔

    拉取一个centos镜像 docker pull centos:centos7 运行一个容器 docker run -i -t -d –restart=always –name…

    Linux 2023年6月6日
    0100
  • Linux文件属性详述

    一、文件属性信息概述 文件属性信息组成如下: 文件索引属性信息——inode编号; 文件类型权限信息; 文件链接属性信息——硬链接数; 文件属主信息——文件所有者; 文件属组属性信…

    Linux 2023年5月27日
    0103
  • Docker如何镜像加速

    原文链接:https://www.zhoubotong.site/post/69.html在使用Docker 下载镜像时,如果不配置镜像加速,下载镜像会比较慢,因为国内从 Dock…

    Linux 2023年6月6日
    0144
  • docker inspect 使用

    获取容器 IP 信息 docker inspect -f {{.NetworkSettings.IPAddress}} centos1 获取容器占用overlay2目录 docke…

    Linux 2023年6月6日
    0113
  • 尝试阅读理解一份linux shell脚本

    从头一二去阅读语法和命令说明,对于脚本小白来说比较枯燥,难以坚持,所以这里选择对一份完整的shell脚本代码来逐行逐段解读,希望可以一渡小白,帮助我们快速进入脚本的大门_。司机要开…

    Linux 2023年6月6日
    091
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球