How to make the Visual Studio compiler ignore a file?

前端 未结 4 701
死守一世寂寞
死守一世寂寞 2020-12-16 01:39

Is anyone aware of a way to make visual studio completely ignore a file when compiling? I have a C# solution that has a foo.config file that isn\'t really a standard config

相关标签:
4条回答
  • 2020-12-16 02:20

    The action to take depends on the solution and and file type. For instance (in VS2005), in a C++ solution I can right click on the source file name in the solution explorer and view its properties. The first "General" option is "Excluded From Build", which will allow you to exclude the file from the build process without having it excluded from the project altogether.

    I pulled up a .config file in a C# solution, and found a "Build Action" option under the Advanced section. That should probably be set to "None".

    0 讨论(0)
  • 2020-12-16 02:26

    right click > properties

    Build Action: set to "None"

    Edit: If you're talking about app.config, you really cant mess with the format of that, you need to put it in a different .config file.

    I just double checked, VS.net doesnt care as long as its not app.config or web.config and the config file build action is set to "None", it will "error" if you have the file open but it will not cause the build to fail or keep it from building the assemblies.

    Close the file and the errors will go away, similar to the errors you get about HTML markup. The displaying of these "errors" is probably a configurable setting in vs.net

    0 讨论(0)
  • 2020-12-16 02:29

    Just right click on the file and choose "Exclude from project".

    If you still want to see it in your project, select the project and click the "Show all files" button at the top of the solution explorer. This will show all the files in the directory tree even if they aren't actually part of the project.

    0 讨论(0)
  • 2020-12-16 02:36

    Are you sure that VS compiling .config file???

    You should check it's Build Action in file options and may be set it to none.

    0 讨论(0)
提交回复
热议问题