NuGet 可以将 .cs 文件添加到目标项目吗? [英] Can NuGet add a .cs file to the destination project?

查看:46
本文介绍了NuGet 可以将 .cs 文件添加到目标项目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个 NuGet 包,在安装期间将 .cs 文件(鼓励包使用者稍后修改的基类)添加到目标项目的根目录.

I want to create a NuGet package that adds a .cs file (a base class the package consumer is encouraged to later modify) to the root of the destination project during installation.

这可能吗?到目前为止,我发现的所有内容都说不,您只能安装包目录下的文件".

Is that possible? Everything I've found so far says "no, you can only install files below the package's directory".

推荐答案

只需将您的 .cs 文件放在包根目录下名为content"的文件夹中.

Just put your .cs file in a folder called "content", at the root of the package.

来自文档:

您可以按照 NuGet 约定布置目录结构.

"you can layout a directory structure that follows the NuGet conventions.

tools - 包的工具文件夹用于可从包管理器控制台访问的 powershell 脚本和程序.将文件夹复制到目标项目后,将其添加到`$env:Path (PATH) 环境变量中.

tools - The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.

lib - 在安装包时将 lib 文件夹中的程序集(.dll 文件)添加为程序集引用.

lib - Assemblies (.dll files) in the lib folder are added as assembly references when the package is installed.

content - 安装包时,内容文件夹中的文件将复制到应用程序的根目录.

content - Files in the content folder are copied to the root of your application when the package is installed.

将 Content 文件夹视为目标应用程序的根目录.比如我想让一个包在目标应用的/images目录下添加图片,一定要把图片放在包的Content/images文件夹下."

Think of the Content folder as the root of your target application. For example, if I want a package to add an image in the /images directory of the target application, make sure to place the image in the Content/images folder of the package."

参见:http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#From_a_convention_based_working_directory

这篇关于NuGet 可以将 .cs 文件添加到目标项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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