2014-07-09 2 views
0

내 모든 로직이 들어있는 Core 클래스 라이브러리가 있습니다.웹 및 콘솔 앱간에 설정 파일 공유하기

IIS를 사용하는 웹 응용 프로그램이 있습니다.

나는 HTTP Listener를 사용하는 콘솔 응용 프로그램을 가지고 있습니다.

두 호스트 프로젝트 모두 connectionStringSource.config 파일이있는 코어 라이브러리를 참조합니다.

호스트 프로젝트는 Core의 connectionStringSource.config에 대한 링크로 추가를 사용하고 Copy To Output (출력에 복사)로 설정했습니다. 은 IIS 호스트 프로젝트의 Web.config의에서 내가 얻을 그러나

<connectionStrings configSource="bin\connectionStringSource.config"></connectionStrings> 

있습니다

[ArgumentException이 :. 경로에 잘못된 문자]
[ConfigurationErrorsException 다음 configSource 속성이 유효하지 않습니다 : 경로에 잘못된 문자가 있습니다. 내가

<connectionStrings configSource="bin/connectionStringSource.config"></connectionStrings> 

로 변경하는 경우 (라인 13)]

IT는 '/'문자가 허용되지 않도록

가 configSource 속성은, 상대의 물리적 경로 여야합니다 말한다.

이러한 설정을 공유 할 수있는 방법이 있습니까?

나는 herehere을 제안했지만 그들은 작동하지 않는 것으로 보인다.

+0

기록 Host.Owin.IIS 버그가 밝혀 그래서이 세 가지 프로젝트를 하나 개의 솔루션? –

+0

@MatijaGrcic 예 – Jon

+0

링크를 "content"로 설정하고 bin 폴더에서 링크를 참조 할 수 있습니까? 틀림없이이 문제를 해결하기보다는 문제 해결을 위해 노력하고 있습니다! – Simon

답변

7

는 모든 프로젝트에

<connectionStrings> 
    <add name="MyContext" 
     connectionString="Data Source=Server\NamedInstance;Initial Catalog=MyDB;Integrated Security=True;MultipleActiveResultSets=True" 
    providerName="System.Data.SqlClient" /> 
</connectionStrings> 

클릭이 들어 내 경우에는 파일 에에 SolutionItems 솔루션 폴더

enter image description here

당신의 connections.config를 추가하고의 app.config를 편집하거나 web.config

0 지금 프로젝트를 클릭 다음 링크로 추가 을 클릭하여 링크로 connections.config을 추가 항목 기존 추가를 선택합니다.

enter image description here

이제 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 선택 언로드 프로젝트

enter image description here

지금 프로젝트를 클릭하고 선택 프로젝트 편집

enter image description here

는 다음과 같은 표시됩니다

<ItemGroup> 
     <None Include="..\connections.config"> 
      <Link>connections.config</Link> 
     </None> 
     <None Include="App.config" /> 
     </ItemGroup> 

우리가 아래로 스크롤하고

<Target Name="CopyLinkedContentFiles" BeforeTargets="Build"> 
    <Copy SourceFiles="%(Content.Identity)" DestinationFiles="%(Content.Link)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Condition="'%(Content.Link)' != ''" /> 
    </Target> 

다시로드 프로젝트 추가 링크 된 콘텐츠 파일을 복사 말할 필요가이 파일을 참조 할 수 있으려면. 프로젝트에 대한

enter image description here

반복은 connections.config을 공유 할 필요가있다.

connections.release.config을 가질 수 있습니다. 그런 다음 Web.Release.config 단지 추가

<connectionStrings xdt:Transform="SetAttributes" configSource="connections.release.config" /> 
관련 문제