2017-03-27 3 views
0

설정 파일/xml 파일에 대한 의존성이 있습니다.이 파일은 uget 패키지로 묶어 놓았으며,이를봤을 때 SO 게시물 또는 두 개를 찾을 수 있습니다. 나는 nuget 패키지를 참조하는 프로젝트가 config/xml 파일을 빌드 할 때 debug/release 출력 폴더에 복사하여 제대로 작동하도록하고 싶습니다. 나는 위의 게시물/블로그에서 언급 한 팁/제안을 시도Nuget xml 파일 종속성

Copy xml from nuget dependency to output

NuGet doesn't copy config file

http://blog.nuget.org/20160126/nuget-contentFiles-demystified.html

,하지만 그런 행운 :

SO 관련 게시물.

이것도 가능합니까? 그렇다면 어떻게?

답변

0

대답은 xml 파일을 "content"로 넣은 다음 nuget "tools"디렉토리의 install.ps1 스크립트를 사용하여 파일을 "Copy To Output"으로 설정하는 것입니다. 중요한 점은이 스크립트는 Visual Studio에서만 실행되므로 모든 콘텐트 파일을 체크인/소스 제어해야하므로 서버가 체크 아웃 할 때 모든 빌드 서버에 콘텐트 파일이 포함되어야합니다. 작지만 믿을 수 없을만큼 중요한 세부 사항 !!

내가 출력 사본으로 콘텐츠 파일을 설정하는 데 사용하는 스크립트 :

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

function SetFilePropertiesRecursivelyByFolderName 
{ 
    $folderKind = "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}"; #Physical Folder 
    foreach ($subItem in $args[0].ProjectItems) 
    { 
     $path = $args[1] 
     if ($subItem.Kind -eq $folderKind) 
     { 
      SetFilePropertiesRecursively $subItem ("{0}{1}{2}" -f $path, $args[0].Name, "\") 
     } 
     else 
     { 
      Write-Host -NoNewLine ("{0}{1}{2}" -f $path, $args[0].Name, "\") 
      SetFileProperties $subItem 2 2 "" 
     } 
    } 
} 

function SetFileProperties 
{ 
    param([__ComObject]$item, [int]$buildAction, [int]$copyTo, [string]$customTool) 
    Write-Host $item.Name 
    Write-Host " Setting Build Action to Content" 
    $item.Properties.Item("BuildAction").Value = $buildAction 
    Write-Host " Setting Copy To Output Directory to Copy if newer" 
    $item.Properties.Item("CopyToOutputDirectory").Value = $copyTo 
    Write-Host " Setting Custom Tool to blank" 
    $item.Properties.Item("CustomTool").Value = $customTool 
} 

function SetIndividualFileProperties 
{ 
    param([string]$fileName) 
    Write-Host $fileName 
    $file1 = $project.ProjectItems.Item($fileName) 
    $file1.Properties.Item("CopyToOutputDirectory").Value = 2 
    $file1.Properties.Item("BuildAction").Value = 2 
} 

#SetFilePropertiesRecursivelyByFolderName $project.ProjectItems.Item("FolderName") 
#SetIndividualFileProperties "FileName.ext" 
관련 문제