[英]How to edit .csproj file
When I am compiling my.csproj file using .NET Framework 4.0 MSBUILD.EXE file, I am getting an error: "lable01" not found in the current context of "website01.csproj".当我使用 .NET Framework 4.0 MSBUILD.EXE 文件编译 my.csproj 文件时,出现错误:在“website01.csproj”的当前上下文中找不到“lable01”。
Actually, I need to add every ASP.NET page with its code-behind file's reference.实际上,我需要添加每个 ASP.NET 页面及其代码隐藏文件的引用。 I've done it, it's working fine, but the above error is pending.我已经完成了,它工作正常,但上述错误未决。
I hope it means that I need to add form name "LABLE01" in that.csproj file, but I do not know the syntax.我希望这意味着我需要在那个 .csproj 文件中添加表单名称“LABLE01”,但我不知道语法。 Anybody please do provide me with the syntax to add form name in.csproj file.请任何人给我提供在 .csproj 文件中添加表单名称的语法。
The CSPROJ
file, saved in XML format, stores all the references for your project including your compilation options. CSPROJ
文件以 XML 格式保存,存储项目的所有引用,包括编译选项。 There is also an SLN file, which stores information about projects that make up your solution.还有一个 SLN 文件,用于存储有关构成您的解决方案的项目的信息。
If you are using Visual Studio and you have the need to view or edit your CSPROJ
file, while in Visual Studio, you can do so by following these simple steps:如果您使用的是 Visual Studio 并且需要查看或编辑您的CSPROJ
文件,则在 Visual Studio 中,您可以按照以下简单步骤进行操作:
You can right click the project file, select "Unload project" then you can open the file directly for editing by selecting "Edit project name.csproj".您可以右键单击项目文件,选择“卸载项目”,然后您可以通过选择“编辑项目名称.csproj”直接打开文件进行编辑。
You will have to load the project back after you have saved your changes in order for it to compile.保存更改后,您必须重新加载项目以进行编译。
See How to: Unload and Reload Projects on MSDN.请参阅如何:卸载和重新加载MSDN 上的项目。
Since project files are XML files, you can also simply edit them using any text editor that supports Unicode (notepad, notepad++ etc...)由于项目文件是 XML 文件,您还可以使用任何支持 Unicode 的文本编辑器(记事本、记事本++等...)
However , I would be very reluctant to edit these files by hand - use the Solution explorer for this if at all possible.但是,我非常不愿意手动编辑这些文件 - 如果可能,请使用解决方案资源管理器。 If you have errors and you know how to fix them manually, go ahead, but be aware that you can completely ruin the project file if you don't know exactly what you are doing.如果您有错误并且知道如何手动修复它们,请继续,但请注意,如果您不确切知道自己在做什么,则可能会完全破坏项目文件。
Since the question is not directly mentioning Visual Studio, I will post how to do this in JetBrains Rider.由于问题没有直接提到 Visual Studio,我将在 JetBrains Rider 中发布如何执行此操作。
From context menu从上下文菜单
With shortcut有快捷方式
There is an easier way so you don't have to unload the project.有一种更简单的方法,因此您不必卸载项目。 Just install this tool called EditProj in Visual Studio:只需在 Visual Studio 中安装这个名为EditProj 的工具:
https://marketplace.visualstudio.com/items?itemName=EdMunoz.EditProj https://marketplace.visualstudio.com/items?itemName=EdMunoz.EditProj
Then right click edit you will have a new menu item Edit Project File :)然后右键单击编辑您将有一个新菜单项编辑项目文件:)
For JetBrains Rider:对于 JetBrains Rider:
First Option第一个选项
Second option:第二种选择:
That's it!就是这样!
Sorry, most efficient way with out stuffing your proj file is.抱歉,最有效的方法是填充您的 proj 文件。
rebuild.重建。
Congratulate your self for being smarter than everyone else and not ****ing you project.祝贺你自己比其他人更聪明,而不是让你做项目。 For me this exercise took under 10 seconds.对我来说,这个练习不到 10 秒。 Where as manually trying to input the compile... line into the csproj not only can render your project unusable but it is also impossible to maintain on large scale application.手动尝试将 compile... 行输入 csproj 不仅会使您的项目无法使用,而且也不可能在大规模应用程序上维护。 Better to keep source version control software to do the updates.最好保留源版本控制软件来进行更新。 If you need to cross merge branches then doing the above is amazing :).如果您需要交叉合并分支,那么执行上述操作非常棒:)。
Here is my option to Edit the project file without the need to Unload the project:这是我无需卸载项目即可编辑项目文件的选项:
Open Solution Explorer and switch to folder view:打开解决方案资源管理器并切换到文件夹视图:
Navigate to the Project which you want to edit inside the Solution folders and right-click on it.在解决方案文件夹中导航到要编辑的项目,然后右键单击它。
That is it!这就对了!
You will see the *.csproj
file opened inside Visual Studio Editor.您将看到在 Visual Studio 编辑器中打开的*.csproj
文件。
After you can switch back to a Solution/Project view (see step 1).在您可以切换回解决方案/项目视图之后(参见步骤 1)。
Update:更新:
Starting from the Visual Studio 2019 (v. 16) you can edit the *.csproj
file by double-clicking on the Project, just make sure that you have the option turned On from the settings.从 Visual Studio 2019 (v. 16) 开始,您可以通过双击项目来编辑*.csproj
文件,只需确保您从设置中打开了该选项。
它是一个内置选项 .Net core 和 .Net 标准项目
For Visual Studio-version: 8.1.5,对于 Visual Studio 版本:8.1.5,
A little late to the conversation but I found a better option.谈话有点晚了,但我找到了一个更好的选择。 In rider you can enable "open project files with single click" Just go to the solution options menu
and then click in open project files with single click
在 rider 中,您可以启用“单击打开项目文件”只需 go 到solution options menu
,然后单击单击open project files with single click
You can also open the.csproj by double-clicking on the project file.您也可以通过双击项目文件打开.csproj。 So no need to right click and select edit project file.因此无需右键单击和 select 编辑项目文件。 Just double click and that is it.只需双击即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.