I'm developing a Visual Studio Extension (vsix). The problem is related to MSBuild, NuGet, and PackageReference.
Context: My VSIX has a ProjectTemplate capable of creating new C# projects with some pregenerated files and code. I have a .nuget folder with a nuget.config pointing to the project's own offline reposiroty containing important offline packages referencing our main application. The offline packages are copied into the project template from the vsix folder.
The problem: The .nuget folder is included in my project template therefore it is located next to the csproj and sln of the created project. As Visual Studio looks for the .nuget folder on sollution level it works fine if I create a new project with my vsix on its own sln. It does not work if I create a new project into an already existing large sln because the sln can be completely somewhere else than my .nuget folder.
Question: How can I tell that "Hey I have a nuget.config file here" upon building the project and ALSO if the user uses the visual studio nuget manager? The fix should be fully automatic, preferably in an msbuild target or someting like that.
I already tried <RestoreAdditionalProjectSources> in MSBuild, but it expects a path to the repo not a nuget.config file.