如何为visual studio中的所有项目创建全局文件? [英] How to create global file for all projects in visual studio?

查看:53
本文介绍了如何为visual studio中的所有项目创建全局文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文件 Pathes.cs(在屏幕截图中);

I have the file Pathes.cs(in the screenshot);

该文件不在任何项目中.其他项目没有看到它.我的任务是使该文件对所有项目可见.我尝试使用 using Homework,在我的项目中使用 Homework.Pathes.pathToDataDirectory.但没有任何帮助.

The file is not in any project. The other projects does not see it. My task is to do that file visible for all projects. I tryed to use using Homework, to use Homework.Pathes.pathToDataDirectory in my projects. But nothing helps.

推荐答案

您有几个选择:

  1. 创建一个类库项目,将文件放在那里,并在需要该类的所有其他项目中引用该项目.右键单击解决方案资源管理器中的 Dependencies,转到 Projects 并选择共享类库项目.这是首选选项.
  2. 将文件链接到需要该文件的项目.右击项目,点击Add>现有项目 并导航到该文件.不要点击 Add 按钮,而是点击它旁边的箭头并选择 Add As Link.
  3. 将文件复制粘贴到项目中.这是一场彻底的维护噩梦,所以不要去那里.
  1. Create a Class Library project, put the file in there and reference that project in all other projects that need that class. Right-click on Dependencies in the Solution Explorer, go to Projects and select the shared class library project. This is the preferred option.
  2. Link the file to the projects that need the file. Right-click on the project, click Add > Existing Item and navigate to the file. Instead of clicking the Add button, click on the arrow next to it and select Add As Link.
  3. Copy-paste the file into the projects. This is a total maintenance nightmare, so don't go there.

这篇关于如何为visual studio中的所有项目创建全局文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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