.net core (csproj) global.json 'projects' equivalent

后端 未结 2 2014
悲哀的现实
悲哀的现实 2020-12-28 20:04

With .net core (project.json) I used to switch between nuget packages and source code by adding the path to source code to the projects field in the global.json

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 20:37

    Yes, I too had gotten used to this functionality and built my workflow around it. I am still looking for a solution but I'm currently playing with the idea of using conditional logic in the csproj files. Since it's now msbuild, you can do things like this:

        
        
            
                
            
        
        
            
                
            
        
    
    

    This replaces the hard reference to a package with a conditional that uses a project reference if it can find the source code (in this case the directory), and a package reference if can't.

    So by default you would be referencing the package, but if you want to debug one of your projects, you check it out in the location that the conditional checks, and add the project to your solution.

    This way you only need to change your solution file (by adding the project) when you want to include source code, instead of rewiring all your project references.

提交回复
热议问题