如何更改 NuGet 包中的目标文件名? [英] How do I change target filename in NuGet Package?
问题描述
JavaScript 命名约定需要文件名中的版本号,例如 jQuery.1.34.min.js
,我有一个文本模板,它将输出 my-library.js
在输出文件夹中.
JavaScript naming convention requires version number in the file name such as jQuery.1.34.min.js
, and I have text template which will output my-library.js
in output folder.
我想用 my-library.js
创建 NuGet 包,安装时应将其部署为 my-library.1.34.js
I want to create NuGet Package with my-library.js
in such way that on installation it should be deployed as my-library.1.34.js
如果我在 msbuild 过程中构建 nuget 包,我无法重命名我的输出 js 文件.
If I build nuget package as part of msbuild process, there is no way I can rename my output js file.
我已经有一个很长的解决方法,其中我有一个控制台应用程序,它将文件复制到给定版本号的文件夹结构,然后它构建一个 nuspec
文件,然后将其传递给 nuget.exe
,如果有什么简单的,我想避免这么长的步骤.
I already have a long workaround, in which I have a console app which copies files to folder structure as given version number and then it builds a nuspec
file and then it is passed onto nuget.exe
, if there is any easy, I would like to avoid such long steps.
推荐答案
我发现我可以通过为目标指定完整文件名来重命名包含文件.
I found I could rename include files by specifying a full file name for the target.
例如(nuspec 片段):
<files>
<file src="my-library.js" target="content/my-library.$VERSION$.js">
</files>
nuget 会像这样运行:
and nuget would be run like:
nuget.exe pack mypackage.nuspec -Prop VERSION=1.34
注意:src和target中的文件扩展名必须匹配,否则指定的target将被视为目录.
Note: The File extension in src and target must match or the specified target will be treated like a directory.
这篇关于如何更改 NuGet 包中的目标文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!