包括引用的项目的.config文件 [英] Include referenced project's .config file

查看:205
本文介绍了包括引用的项目的.config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而不是从引用的输出中排除文件的装配体,我想添加一个!

Rather than excluding a file from the referenced output of an assembly, I want to add one!

我有一个控制台应用程序项目(BuildTest1),该项目引用了第二个类库项目(ClassLibrary1). Visual Studio解决方案如下所示:

I have a console application project (BuildTest1) that references a second class library project (ClassLibrary1). The Visual Studio solution looks like this:

我有一个具有app.config的类库项目.我希望将此.config文件复制到引用项目的输出,就像.dll和.pdb文件一样.将类库的配置文件复制为类库输出目录,即"ClassLibrary1.dll.config"

I have a class library project that has an app.config. I want this .config file copied to the referring project's output, just like the .dll and .pdb files are. The config file for the class library is copied to the class library output directory as 'ClassLibrary1.dll.config'

我尝试将其添加到.exe项目的.csproj文件中,但似乎没有什么区别:

I've tried adding this to the .exe project's .csproj file but it doesn't seem to make any difference:

  <PropertyGroup>
    <AllowedReferenceRelatedFileExtensions>
        .pdb;
        .xml;
        .config
    </AllowedReferenceRelatedFileExtensions>
  </PropertyGroup>

推荐答案

我是如此接近...我将其追溯到MSBuild

I was so close... I tracked this down to the MSBuild ResolveAssemblyReference task that is called from the ResolveAssemblyReferences target in Microsoft.Common.targets. This is what populates the ReferenceCopyLocalPaths item.

因此,查看文件模式是否匹配,我发现文件扩展名为.dll.config(而不只是.config)可以解决问题:

So looking at the pattern of files it was matching I discovered that the file extension .dll.config (rather than just .config) did the trick:

<PropertyGroup>
    <AllowedReferenceRelatedFileExtensions>
        .pdb;
        .xml;
        .dll.config
    </AllowedReferenceRelatedFileExtensions>
</PropertyGroup>

这篇关于包括引用的项目的.config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆