2012-03-18 3 views
0

MEF 플러그인 용 nuspec을 작성하고 싶습니다. 아래와 같이 xxx.dll을 콘텐츠 디렉토리에 복사 할 수 있습니다.MEF 플러그인 파일 용 Nuspec 작성 방법

<files> 
    <file src="Alhambra\bin\Release\Plugins\Alhambra.Plugin.SqlServer.dll" target="content\Plugins\Alhambra.Plugin.SqlServer.dll" /> 
    <file src="Alhambra\bin\Release\Alhambra.dll" target="lib\Alhambra.dll" /> 
</files> 

사용자 프로젝트에서 출력 디렉토리를 복사하는 파일 속성을 설정할 수 없습니다.

제안이나 코드 스 니펫을 보내 주셔서 감사합니다.

답변

0

내 접근 방식은 프로젝트에 별도의 파일로 플러그인을 추가하는 것입니다. 이를 위해 설치 스크립트가 필요합니다 (NuGet docs for this 참조).

이에 대한 나의 솔루션은 다음 스크립트입니다

PARAM ($의 installPath, $ toolsPath, $ 패키지 $ 프로젝트) 물론

Function add_file($file) 
{ 
    $do_add = 1 
    foreach($item in $project.DTE.ActiveSolutionProjects[0].ProjectItems) 
    { 
     if ($item -eq $file) 
     { $do_add = 0 } 
    } 
    if ($do_add -eq 1) 
    { 
     $added = $project.DTE.ItemOperations.AddExistingItem($file) 
     $added.Properties.Item("CopyToOutputDirectory").Value = 2 
     $added.Properties.Item("BuildAction").Value = 0   
    } 
} 
add_file(<file1>) 
add_file(<file2>) 

, 사용자가 패키지를 제거 할 때, 당신이 필요로하는 정리하기 :

param($installPath, $toolsPath, $package, $project) 

Function remove_file($file) 
{ 
    foreach($item in $project.DTE.ActiveSolutionProjects[0].ProjectItems) 
    { 
     if ($item.Name -eq $file) 
     { 
      $item.Delete() 
     } 
    } 
} 
remove_file(<file1>) 
remove_file(<file2>) 
+0

nuget 콘솔에서 "install-package"명령을 사용할 때는 작동하지 않습니다. 솔루션 항목으로 파일을 추가하려고합니다. – miracle2k