简体   繁体   English

VS2010和VS2012的两个C#项目文件在同一目录中

[英]Two C# project files for VS2010 and VS2012 in the same directory

I'm writing a C# project which I want to compile both under VS2010 and VS2012. 我正在编写一个C#项目,我想同时在VS2010和VS2012下进行编译。 I want to have two different .csproj files for that, even though VS2010-project can be directly included in VS2012-solution. 我想为此使用两个不同的.csproj文件,即使VS2010-project可以直接包含在VS2012-solution中。 I want two different project files because of different target .NET-versions. 由于目标.NET版本不同,我需要两个不同的项目文件。

Additionally, I want both projects to be named the same within different solutions for VS2010 and VS2012. 另外,我希望两个项目在VS2010和VS2012的不同解决方案中被命名为相同的名称。 The both should share the same .cs -files and, possibly, some resources. 两者应该共享相同.cs -files,可能还有一些资源。

Easy task? 简单的任务? Strange thing, but I don't know, how to do that properly. 奇怪的事情,但我不知道如何正确执行。

  • First approach, doesn't work: name project files as MyProject10.csproj and MyProject12.csproj , leave both in the MyProject folder. 第一种方法不起作用:将项目文件命名为MyProject10.csprojMyProject12.csproj ,将两者都保留在MyProject文件夹中。 But in this case they are displayed in solution as MyProject10 and MyProject12 , not simply MyProject . 但是在这种情况下,它们在解决方案中显示为MyProject10MyProject12 ,而不仅仅是MyProject If I rename one to MyProject in solution explorer, it automatically renames the corresponding project file. 如果在解决方案资源管理器中将一个重命名为MyProject ,它将自动重命名相应的项目文件。

  • Second approach, works, but has drawbacks. 第二种方法可行,但有缺点。 Move project files into different subdirectories, named VS10 and VS12 , manually change include paths in .csproj -files, adding ..\\ as a prefix. 将项目文件移动到名为VS10VS12不同子目录中,手动更改.csproj -files中的包含路径,并添加..\\作为前缀。 In this case I see strange shortcut-like arrows under the icons in solution explorer. 在这种情况下,我在解决方案资源管理器的图标下看到奇怪的类似于快捷方式的箭头。

The only bad thing for the second approach is that when I add new files in the project using solution explorer, this file is placed in the VS10 subdirectory, not in the root project directory. 第二种方法的唯一坏处是,当我使用解决方案资源管理器在项目中添加新文件时,该文件位于VS10子目录中,而不是在根项目目录中。 But it seems like project directories for .csproj -files are the directories containing the file by design, and I use the dark side of the force which I really don't want to do. 但是,似乎.csproj -files的项目目录是按设计包含文件的目录,而我使用的是我实际上不想做的事情的阴暗面。

Any better ideas? 还有更好的主意吗?

Worth giving a try is changing the name of the output assembly in both projects to one and the same. 值得一试的是将两个项目中输出程序集的名称更改为一个。 The project files are still going to be different, but the output assembly will be with same name. 项目文件仍将有所不同,但是输出程序集将具有相同的名称。 Also be carefull where is the output directory. 还要注意输出目录在哪里。 I think this way you can sovle your problem. 我认为这样可以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VS2010 C ++ / CLI项目总是认为VS2012 C#项目已经过时了 - VS2010 C++/CLI project always thinks VS2012 C# project is out of date 如何在VS2010和VS2012中加载数据库项目? - How to load database project in VS2010 and VS2012? 将项目从VS2010迁移到VS2012后无法继承接口 - can't inherit interface after migrating project from VS2010 to VS2012 在项目开发过程中从VS2010升级到VS2012会有任何风险吗? - Is there any risk in upgrading from VS2010 to VS2012 in the middle of project development? DeploymentItem在VS2010和VS2012中的行为方式不同 - DeploymentItem behaving differently in VS2010 and VS2012 在VS2012和VS2010上运行相同的程序表现出不同的行为 - Running same program on VS2012 and VS2010 exhibits different behavior 如何通过c#编程打开带有某些项目的Visual Studio exe(VS2008,VS2010,VS2012,VS2013)? - How to open Visual Studio exe's(VS2008,VS2010,VS2012,VS2013) with some projects by programming in c#? 从VS2010升级到VS2013(或VS2012)后,无法打开Visual Studio C#解决方案,错误消息“不支持给定路径的格式” - Can not open Visual Studio C# solution after upgrading from VS2010 to VS2013 (or VS2012), error message “The given path's format is not supported” 如何在使用VS2012创建的Blend 4中编辑ac#project? - How to edit a c# project in Blend 4 that was created with VS2012? AppFabric DataCacheFactory()初始化在VS2013中挂起,在VS2010和VS2012中正常工作 - AppFabric DataCacheFactory() initialization hangs in VS2013, works fine in VS2010 and VS2012
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM