当我使用. net Framework 4.0 MSBUILD.EXE文件编译我的.csproj文件时,我得到一个错误:“lable01”没有在“website01.csproj”的当前上下文中找到。

实际上,我需要添加每一个ASP。NET页面及其代码隐藏文件的引用。我已经做到了,它工作得很好,但上面的错误是悬而未决的。

我希望这意味着我需要在.csproj文件中添加表单名称“LABLE01”,但我不知道语法。谁能告诉我在。csproj文件中添加表单名的语法。


当前回答

这是我的选项编辑项目文件,而不需要卸载项目:

打开解决方案资源管理器,切换到文件夹视图: 导航到解决方案文件夹中要编辑的项目,并右键单击它。 从上下文菜单中选择打开。

就是这样!

你会看到*。在Visual Studio编辑器中打开csproj文件。 之后,您可以切换回解决方案/项目视图(参见步骤1)。


更新:

从Visual Studio 2019 (v. 16)开始,您可以编辑*。通过双击项目来打开csproj文件,只需确保从设置中打开了该选项。

其他回答

对于Visual studio版本:8.1.5,

右键单击项目文件夹。 点击“工具”,然后点击“编辑文件”。

您可以右键单击项目文件,选择“卸载项目”,然后通过选择“编辑项目名称。csproj”直接打开文件进行编辑。

您必须在保存更改后重新加载项目,以便对其进行编译。

参见如何:在MSDN上卸载和重新加载项目。


由于项目文件是XML文件,您还可以使用任何支持Unicode的文本编辑器(notepad, notepad++等…)

然而,我非常不愿意手动编辑这些文件——如果可能的话,使用解决方案资源管理器。如果你有错误,你知道如何手动修复它们,继续,但要注意,如果你不知道你在做什么,你可能会完全破坏项目文件。

这是我的选项编辑项目文件,而不需要卸载项目:

打开解决方案资源管理器,切换到文件夹视图: 导航到解决方案文件夹中要编辑的项目,并右键单击它。 从上下文菜单中选择打开。

就是这样!

你会看到*。在Visual Studio编辑器中打开csproj文件。 之后,您可以切换回解决方案/项目视图(参见步骤1)。


更新:

从Visual Studio 2019 (v. 16)开始,您可以编辑*。通过双击项目来打开csproj文件,只需确保从设置中打开了该选项。

抱歉,最有效的方法,而不是填充您的proj文件是。

right click the file. goto properties where Build Action option is set it to NONE. Do a build (yes you may get build error if you do even better) go back to properties of that file set Build Action option is set it back to Compile. rebuild. Congratulate your self for being smarter than everyone else and not ****ing you project. For me this exercise took under 10 seconds. 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. Better to keep source version control software to do the updates. If you need to cross merge branches then doing the above is amazing :).

您还可以通过双击项目文件来打开.csproj。所以不需要右键单击并选择编辑项目文件。只需双击,就完成了。