Make reference to C# code from multiple projects

后端 未结 4 1433
走了就别回头了
走了就别回头了 2020-12-19 04:08

I have a .cs file full of C# code I keep reusing in multiple projects.

Right now I\'m including it in these projects by copying and pasting the code int

4条回答
  •  悲哀的现实
    2020-12-19 04:51

    I wrote an app that automates adding a code as a link, handy for projects that reuse a lot of code and change a bit. It's at https://github.com/CADbloke/CodeLinker

    or

    Don't be afraid to edit XML .csproj files. For instance, this works ...

    
    Libs\%(RecursiveDir)%(Filename)%(Extension)
    
    

    ...and will give you all the C# files from the source folder, and subfolders, as linked files in your destination project.

    • $(Codez) is a Windows Environment Variable I use on my PCs.
    • I also could have used *.* at the end instead of *.cs.
    • This is one of those things Visual Studio might break on you, adding a file into the folder full of wildcard-linked files may break them out to separate entries. Or not. Depends on the wind.

提交回复
热议问题