콘텐츠에 일부 파일이 포함 된 NuGet 패키지를 만들고 싶습니다.이 파일을 프로젝트에 추가하고 프로젝트에서 참조하지 않기를 바랍니다. 따라서 컴파일되지 않습니다. 나는 이것에 대해 어떻게 갈 것인가?NuGet 콘텐츠 프로젝트 참조 제외
감사
콘텐츠에 일부 파일이 포함 된 NuGet 패키지를 만들고 싶습니다.이 파일을 프로젝트에 추가하고 프로젝트에서 참조하지 않기를 바랍니다. 따라서 컴파일되지 않습니다. 나는 이것에 대해 어떻게 갈 것인가?NuGet 콘텐츠 프로젝트 참조 제외
감사
을 편집 nuspec 파일을 다음처럼 파일 참조에 넣어 :
<?xml version="1.0"?>
<package>
<metadata>
...
</metadata>
<files>
...
<file src="MyFirstContentFile.txt" target="content" />
<file src="MySecondContentFile.cs" target="content" />
...
</files>
</package>
대상 = "내용" 비트에 파일을 복사의 마법을 무엇이다 귀하의 프로젝트.
이제 프로젝트로 가져 오는 파일이 코드 파일 (예 : .cs 파일)이고 파일을 컴파일하지 않으려면 해당 파일의 빌드 작업을 설정해야합니다. 이렇게하려면 install.ps1 파일에 대한 작업을 수행해야합니다 (아직 하나가없는 경우 파일을 만들고 target = "tools"를 사용하여 파일 섹션에서 파일을 참조하는 것을 잊지 마십시오) :
param($installPath, $toolsPath, $package, $project)
$file1 = $project.ProjectItems.Item("MyFirstContentFile.txt")
$file2 = $project.ProjectItems.Item("MySecondContentFile.cs")
# set 'BuildAction' to 'Content'
$copyToOutput1 = $file1.Properties.Item("BuildAction")
$copyToOutput1.Value = 2
$copyToOutput2 = $file2.Properties.Item("BuildAction")
$copyToOutput2.Value = 2
BuildAction 열거 형의 가능한 값은 다음 링크를 참조하십시오. http://msdn.microsoft.com/en-us/library/aa983962(VS.71).aspx