指定内容的构建动作-Nuget [英] specify build action of content - Nuget
问题描述
告诉Nuget软件包将所有css文件添加为嵌入式资源的最简单方法是什么(即,构建操作是嵌入式资源).
What is the simplest way to tell Nuget package to add all css files as an embedded resource (ie build action is embedded resource).
我正在尝试通过tools文件夹中的install.ps1进行操作,但仍然无法到达任何地方
I am trying to do it through install.ps1 in the tools folder but still cant get anywhere
注意:我是从目录结构(tools \ content \ lib)创建程序包
Note: I am creating the package from the directory structure(tools\content\lib)
这是我的install.ps1,不起作用.
This is my install.ps1 which does not work.
param($installPath, $toolsPath, $package, $project)
$MsbNS = @{msb = 'http://schemas.microsoft.com/developer/msbuild/2003'}
function EmbeddContent($ProjectLink, [string]$XPath)
{
$nodes = @(Select-Xml $XPath $ProjectLink -Namespace $MsbNS | Foreach {$_.Node})
foreach ($node in $nodes)
{
if($node.Include.StartsWith("Content\css"))
{
$cet = $node.ownerdocument.CreateElement("EmbeddedResource")
$cet.setAttribute("Include", $node.Include)
$parent = $node.ParentNode
[void]$parent.RemoveChild($node)
[void]$parent.Appendchild($cet)
}
}
}
$project.Save()
$fileLocation = $project.FileName
$dte.ExecuteCommand("Project.UnloadProject");
$proj = [xml](gc $fileLocation)
Embeddcontent $fileLocation '//msb:Project/msb:ItemGroup/msb:Content'
$proj.Save($fileLocation)
请帮助..
推荐答案
您可以使用DTE而不是弄乱xml来更改BuildAction.来自 http://nuget.codeplex.com/discussions/227696 :
You can use DTE instead of messing with xml to change the BuildAction. From http://nuget.codeplex.com/discussions/227696:
$item = $project.ProjectItems | where-object {$_.Name -eq "ReleaseNotes.txt"}
$item.Properties.Item("BuildAction").Value = [int]3
此链接显示枚举值: http://msdn.microsoft.com/en-us/library/aa983962(VS.71).aspx
This link shows the enumeration values: http://msdn.microsoft.com/en-us/library/aa983962(VS.71).aspx
这篇关于指定内容的构建动作-Nuget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!