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

With .net core (project.json) I used to switch between nuget packages and source code by adding the source code path to the projects field in global.json. After I have done this, it will add all the projects that it can find in this path, which can replace the nuget packages that I referenced.

I used this function because I have my own nuget packages that I use, but I want to check the changes in my other project before publishing. But as soon as I switched to the Sdk 1.0.0 / VS 2017 / csproj.net kernel, the function seemed to disappear.

An alternative is simply to add each project manually, switch links manually (since they are divided into project links, nuget and sdk), and then switch everything back after switching.

Any thoughts or advice would be great.

UPDATE: It appears that there is no equivalent in csproj (as expected), but there are currently msbuild workarounds (starting from the original version of VS 2017 / .NET Core SDK 1.0.0)

+7
asp.net-core nuget .net-core csproj
source share
2 answers

Yes, I’m also used to this functionality and created my own workflow around it. I'm still looking for a solution, but now I'm playing with the idea of ​​using conditional logic in csproj files. Since this is now msbuild, you can do things like this:

  <Choose> <When Condition="Exists('..\..\..\MyProject')"> <ItemGroup> <ProjectReference Include="..\..\..\MyProject\src\MyProject\MyProject.csproj" /> </ItemGroup> </When> <Otherwise> <ItemGroup> <PackageReference Include="MyProject" Version="1.0.0" /> </ItemGroup> </Otherwise> </Choose> 

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

Thus, by default you will refer to the package, but if you want to debug one of your projects, you check it in the place where conditional checks are performed, and add the project to your solution.

Thus, you only need to modify the solution file (adding the project) if you want to include the source code, instead of rewriting all the links to the project.

+8
source share

For others who are interested in trying to emulate working with Global.json, I worked on it, now using a couple of powershell scripts and a custom json file that mimics. See my answer here: fooobar.com/questions/845230 / ...

+1
source share

All Articles