如何通过 NuGet 包安装更改现有文件? [英] How Do You Change an Existing File Via a NuGet Package Install?

查看:63
本文介绍了如何通过 NuGet 包安装更改现有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改通过 NuGet 包存在的文件的内容?意思是,假设您制作了一个全新的 MVC3 网站.您想要安装将更新主页的 NuGet 包.也许更改欢迎消息,然后更改布局以包含您创建的一些新视图,并更新主控制器以包含返回新视图的方法.这将如何完成?

Is it possible to change the contents of a file that exists via a NuGet package? Meaning, let's say you make a brand new MVC3 website. You want to install a NuGet package that will update the home page. Maybe change the welcome message and then change the layout to include some new View you've created and update the Home Controller to include a method to return your new View. How would this be done?

推荐答案

安装 NuGet 包后,您可以手动修改所需的任何文件.只需在 VS(或使用其他编辑器)中编辑它们.NuGet 包的唯一区别是,如果在原始包文件和文件之间检测到更改时卸载/更新包,则不会删除修改的文件.将要提到这是日志.

After you've installed the NuGet Package you can manually modify any files you want. Just edit them in VS (or with another editor). The only difference regarding NuGet packages is that your modified files won't be removed if you uninstall/update the package as changes are detected between the original package files and your files. There's going to be a mention of this is the logs.

更新:

NuGet 支持在包安装期间通过 .transform 和 .pp 文件.但这有局限性,.transform 文件将内容添加到配置文件(它们无法编辑),而 .pp 文件用于新的源代码文件.

NuGet has supports for modifying project files during a package installation through .transform and .pp files. But this has limitations, .transform files adds content to config files (they can't edit) while .pp files are for new source code files.

您可以使用 EnvDte CodeModel 修改现有源代码PowerShell(即 install.ps1).不过它有点复杂.

You can modify existing source code using EnvDte CodeModel in PowerShell (i.e. install.ps1). It's a bit more complex though.

这篇关于如何通过 NuGet 包安装更改现有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆