【发布时间】:2017-09-29 10:56:12
【问题描述】:
标题说明了一切。我有一些文件要在安装 NuGet 包的过程中嵌套,但不能使用 PowerShell 脚本,因为它们将不再运行(see here)。
还有其他方法可以实现这个目标吗?
更新: 嵌套是指*.resx 和*.Designer.cs 或*.xaml 和代码隐藏文件*.xaml.cs。我知道我可以通过在 *.csproj 文件中添加 <DependentUpon> 元素来实现这一点,但我不知道如何在不使用 PowerShell 的情况下添加该元素。
UPDATE2: init.ps1 runs the first time a package is installed in a solution。但这不会削减它。当包安装到项目中时,我需要运行脚本,就像 install.ps1 运行到 NuGet3。
UPDATE3:我要做的是将3个文件添加到目标项目的Properties文件夹中(Resources.resx、Resources.tt和Resources.Designer.cs)。它们是通常资源实施的替代品。这些文件由 nuget 包在添加到项目时安装。
这是*.nuspec 文件的一部分,将它们添加到包的Content 文件夹中。由于其中只有一个实际上是内容(其他分别是嵌入式资源和编译),因此能够相应地设置它们的构建操作,但一次一步。
<files>
<file src="Properties\Resources.resx" target="content\Properties\Resources.resx" />
<file src="Properties\Resources.tt.pp" target="content\Properties\Resources.tt.pp" />
<file src="Properties\Resources.Designer.cs" target="content\Properties\Resources.Designer.cs" />
</files>
由于这些文件被添加到项目中,我希望嵌套在 *.csproj 文件中,并且如果可能的话,不要通过单独的 *.props 文件发生。
【问题讨论】:
-
“嵌套文件”是什么意思?在你的 nupkg 中创建一个树结构?
-
@MartinUllrich 请看我的更新
-
Powershell script support was modified to no longer execute install and uninstall scripts, but init scripts are still executed一些 脚本将不再运行...但其他脚本会! -
@gvee Init.ps1 runs the first time a package is installed in a solution。但这不会削减它。当包安装到项目中时,我需要运行脚本。
-
您是否真的需要一个脚本来布置文件,或者只是预先布置您的 nuget 内容以便将其按原样安装在正确的目录中?我们使用带有
<itemgroup><file include=...><targetpath>TopDir\NesteDir\...</targetpath>...的 .nuproj 条目
标签: powershell nuget nuget-package