Automatically copy config file from dll link
I have 2 projects in my VS2005 solution: Exe.csproj and Dll.csproj
Dll.csproj has app.config
Exe.csproj has a project link for Dll.csproj
If I compile Exe.csproj then Dll.dll and Dll.pdb are copied to Exe / bin / debug automatically, but Dll.dll.config is not.
Is there a way to get Dll.dll.config in Exe / bin / debug without using post build method?
+2
Zhenya
source
to share
2 answers
Right click on the file (Dll.dll.config) and view its properties.
Set Copy to Local to True. This will automatically place the file in the output directory.
Kindness,
Dan
0
Daniel elliott
source
to share
MSBuild to the Rescue!
Insert the following targets into the project file:
<Target Name="CopyConfig"
Inputs="@(DetectedConfig)"
Outputs="@(DetectedConfig->'$(OutDir)%(Filename)%(Extension)')"
AfterTargets="DetectConfigFiles">
<Copy SourceFiles="@(DetectedConfig)"
DestinationFiles="@(DetectedConfig->'$(OutDir)%(Filename)%(Extension)')">
<Output TaskParameter="CopiedFiles"
ItemName="CopiedConfig" />
</Copy>
<Message Importance="High"
Condition="'%(CopiedConfig.FullPath)'!=''"
Text="Copied config: %(CopiedConfig.FullPath)" />
</Target>
<Target Name="DetectConfigFiles" AfterTargets="ResolveAssemblyReferences">
<ItemGroup>
<!-- Add .config onto all the assemblies we reference -->
<PossibleConfig Include="%(ReferencePath.FullPath).config" />
</ItemGroup>
<!-- Work out which ones actually exist in the file system -->
<ItemGroup>
<DetectedConfig Include="@(PossibleConfig)" Condition="Exists('%(PossibleConfig.Identity)')" />
</ItemGroup>
</Target>
+2
LukeN
source
to share