简体   繁体   English

打开没有 .sln / .csproj 文件的 C# 项目

[英]Opening a C# project without .sln / .csproj file

I'm confronted with a (seemingly) C# project.我遇到了一个(看似)C# 项目。 However, there is no .sln or .csproj file.但是,没有 .sln 或 .csproj 文件。

However, I see a CMakeList.txt.但是,我看到了一个 CMakeList.txt。 I have added its contents at the end of this question.我在这个问题的末尾添加了它的内容。

How could I open this project in VS 2019?我怎样才能在 VS 2019 中打开这个项目? Or is there something missing in order to open the project?或者为了打开项目缺少什么? Before asking the producer and perhaps stand like a complete newbie, I wanted to make sure there is nothing I have forgotten.在询问制作人之前,也许像一个完全的新手一样站着,我想确保我没有忘记任何事情。

Here is a list of the files that I have:这是我拥有的文件列表:

在此处输入图片说明 Contents of CMakeList.txt: CMakeList.txt 的内容:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT( IrisbondAPITestCS LANGUAGES CSharp)

INCLUDE( CSharpUtilities )


SET( PROGRAM_SRC 
    App.config
    Program.cs
    Test.cs
    Test.Designer.cs
    Test.resx
    IrisbondDuo.cs
    WinAPI.cs
    MouseInput.cs
    NativeMethods.cs
)

SET( PROPERTIES_SRC 
    Properties/AssemblyInfo.cs
    Properties/Resources.Designer.cs
    Properties/Resources.resx
    Properties/Settings.Designer.cs
    Properties/Settings.settings
)

ADD_EXECUTABLE(${PROJECT_NAME} ${PROGRAM_SRC} ${PROPERTIES_SRC} )

CSHARP_SET_WINDOWS_FORMS_PROPERTIES(
    Test.cs
    Test.Designer.cs
    Test.resx
)

CSHARP_SET_WINDOWS_FORMS_PROPERTIES( ${PROPERTIES_SRC} )


# set_property(SOURCE App.xaml PROPERTY VS_XAML_TYPE "ApplicationDefinition")

SET_PROPERTY( TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.1")
SET_PROPERTY( TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE TRUE)

SET_PROPERTY( TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES
    "Microsoft.CSharp"
    "System"
    "System.Core"
    "System.Data"
    "System.Data.DataSetExtensions"
    "System.Deployment"
    "System.Drawing"
    "System.Windows.Forms"
    "System.Xml"
    "System.Xml.Linq"
)

ADD_DEPENDENCIES( ${PROJECT_NAME} IrisbondAPI) 

Edit: This is what my VS2019 Community looks like:编辑:这就是我的 VS2019 社区的样子:

在此处输入图片说明

The built-in solution to this issue is explained in this doc .文档中解释了此问题的内置解决方案。 It uses the Create Project from Existing Code Files wizard , which you can get to by going to File > New > Project From Existing Code .它使用Create Project from Existing Code Files wizard ,您可以通过转到File > New > Project From Existing Code来访问该Create Project from Existing Code Files wizard

However, if for some reason the built in solution does not work for you (OP for example, did not have that option. The wizzard might not be available on the community version of VS2019), you can take one of these routes:但是,如果由于某种原因内置解决方案对您不起作用(例如 OP,没有该选项。该向导可能在 VS2019 的社区版本上不可用),您可以采用以下路线之一:

If your properties folder is not important:如果您的properties文件夹不重要:

  1. Create a new project.创建一个新项目。
  2. Move your files in the new project's folder.将文件移动到新项目的文件夹中。 (excluding the properties folder) (不包括属性文件夹)
  3. You will have to add the code files to the .csproj manually.您必须手动将代码文件添加到.csproj Either by modifying it directly (which is not always fun), or simply showing all hidden files like so and including them into the solution right click on item > Include In Project .通过直接修改它(这并不总是很有趣),或者只是像这样显示所有隐藏文件并将它们包含到解决方案中right click on item > Include In Project
  4. That's it, things should work.就是这样,事情应该起作用了。 5. 5.

If your properties folder is important:如果您的properties文件夹很重要:

  1. Create a new project.创建一个新项目。
  2. Unload the project right click ont he project > Unload project卸载项目right click ont he project > Unload project
  3. Move your files in the new project's folder.将文件移动到新项目的文件夹中。 Replace the conflicts in the properties folder.替换properties文件夹中的冲突。
  4. You will have to add the code files to the .csproj manually.您必须手动将代码文件添加到.csproj Either by modifying it directly (which is not always fun), or simply showing all hidden files like so and including them into the solution right click on item > Include In Project .通过直接修改它(这并不总是很有趣),或者只是像这样显示所有隐藏文件并将它们包含到解决方案中right click on item > Include In Project 5.That's it, things should work. 5.就是这样,事情应该起作用了。

Edit: FYI (didn't know myself), did some research on the make file in your folder, it's something used in the CLion IDE, so that is why there was no VS solution in there to begin with.编辑:仅供参考(我不知道),对您文件夹中的make文件进行了一些研究,它是CLion IDE 中使用的东西,所以这就是为什么那里没有 VS 解决方案的原因。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM