I have a Visual Studio 2019 solution that looks like this and I want to package it into a nuget repo:
-Solution
+Project1
(no web.config file)
+Project2
-web.config.transform
<appSettings>
<add key="Project2Key" value="p2value" />
</appSettings>
+Project3
-web.config.transform
<appSettings>
<add key="Project3Key" value="p3value" />
</appSettings>
<customSettingsForProject3>
.....
</customSettingsForProject3>
+MainUtilsProject
-web.config.transform
<appSettings>
<add key="MainUtilsProjectKey" value="mainValue" />
</appSettings>
When it compiles it runs the nuget pack command to generate a nuget package (all that works fine). The problem is that only the web.config.transform in the MainUtilsProject gets packaged. The other web.configs are either not copied, overwritten or not transformed. The "Copy Always" is set on those files.
The nuspec has
<file src="web.config.transform" target="Content" />
in the files node.
I know that they are all the same name and that the last one in will be the only one that exists after the build, but if I rename the web.configs in the other projects they all get copied to the bin folder but the nuget pack command fails if I try to reference them saying "file not found".
The ultimate aim is to have the consuming project that downloads the nuget package install the relevant sections of the web.configs into it's own web.config. And this works perfect but only for the MainUtilsProject file (In the example below it only has the key for the MainUtilsProject inserted)
So how can I get the web.configs for all the projects merged into one file that gets packed into the nuget package? Bearing in mind that the projects can also exist as independent projects with their own web.configs.
In the consuming project, after I install the nuget package, I would like to see this in the web.config file:
<appSettings>
<add key="Project2Key" value="p2value" />
<add key="Project3Key" value="p3value" />
<add key="MainUtilsProjectKey" value="mainValue" />
</appSettings>
<customSettingsForProject3>
.....
</customSettingsForProject3>
Is it even possible?
Thanks