Cmd 来自“.csproj”的Nuget pack不';t替换样本值

Cmd 来自“.csproj”的Nuget pack不';t替换样本值,cmd,nuget,nuget-spec,Cmd,Nuget,Nuget Spec,我正在尝试自动构建nuget包,但我在示例值方面有一些问题,即许可证URL、图标URL等。我希望能够替换项目URL、标记和摘要,同时完全删除许可证URL和图标URL。。。我正在从CMD自动执行此操作,我找不到这些值的任何属性,我可以将其粘贴在程序集信息中。。。我该怎么做?我发现这样设置是不可能的,所以我只需要使用nuget spec然后使用批处理操作更改文件。有关后续参考,请参见以下相关批次: nuget spec Extensions.csproj REM create the file R

我正在尝试自动构建nuget包,但我在示例值方面有一些问题,即许可证URL、图标URL等。我希望能够替换项目URL、标记和摘要,同时完全删除许可证URL和图标URL。。。我正在从CMD自动执行此操作,我找不到这些值的任何属性,我可以将其粘贴在程序集信息中。。。我该怎么做?

我发现这样设置是不可能的,所以我只需要使用
nuget spec
然后使用批处理操作更改文件。有关后续参考,请参见以下相关批次:

nuget spec Extensions.csproj REM create the file

REM deletes all occurences of the licenseUrl
set count=1
for /f "delims=" %%A in ('find /V /I "<licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>" Extensions.nuspec') do (
if !count!==1 echo.>Extensions.nuspec
if !count! GTR 1 echo %%A>>Extensions.nuspec
set /A count=!count!+1)

REM deletes all occurences of the IconUrl
set count=1
for /f "delims=" %%A in ('find /V /I "<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>" Extensions.nuspec') do (
if !count!==1 echo.>Extensions.nuspec
if !count! GTR 1 echo %%A>>Extensions.nuspec
set /A count=!count!+1)

REM replaces values with new values
call :FindReplace "Tag1" "C#" Extensions.nuspec
call :FindReplace "Tag2" "Extensions" Extensions.nuspec
call :FindReplace "http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE" "http://www.gitlab.com/roconnor/Extensions" Extensions.nuspec

exit /b 

:FindReplace <findstr> <replstr> <file>
set tmp="%temp%\tmp.txt"
If not exist %temp%\_.vbs call :MakeReplace
for /f "tokens=*" %%a in ('dir "%3" /s /b /a-d /on') do (
  for /f "usebackq" %%b in (`Findstr /mic:"%~1" "%%a"`) do (
    echo(&Echo Replacing "%~1" with "%~2" in file %%~nxa
    <%%a cscript //nologo %temp%\_.vbs "%~1" "%~2">%tmp%
    if exist %tmp% move /Y %tmp% "%%~dpnxa">nul
  )
)
del %temp%\_.vbs
exit /b

:MakeReplace
>%temp%\_.vbs echo with Wscript
>>%temp%\_.vbs echo set args=.arguments
>>%temp%\_.vbs echo .StdOut.Write _
>>%temp%\_.vbs echo Replace(.StdIn.ReadAll,args(0),args(1),1,-1,1)
>>%temp%\_.vbs echo end with
nuget spec Extensions.csproj REM创建文件
REM删除licenseUrl的所有事件
设置计数=1
对于/f“delims=“%%A in('find/V/I)”http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE“Extensions.nuspec”)怎么办(
if!count!==1 echo.>Extensions.nuspec
如果!计数!GTR 1 echo%%A>>Extensions.nuspec
设置/A计数=!计数!+1)
REM删除IconUrl的所有出现
设置计数=1
对于/f“delims=“%%A in('find/V/I)”http://ICON_URL_HERE_OR_DELETE_THIS_LINE“Extensions.nuspec”)怎么办(
if!count!==1 echo.>Extensions.nuspec
如果!计数!GTR 1 echo%%A>>Extensions.nuspec
设置/A计数=!计数!+1)
REM用新值替换值
调用:FindReplace“Tag1”“C#”Extensions.nuspec
调用:FindReplace“Tag2”“Extensions”Extensions.nuspec
电话:FindReplace“http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE" "http://www.gitlab.com/roconnor/Extensions“1.nuspec
退出/b
:FindReplace
设置tmp=“%temp%\tmp.txt”
如果不存在%temp%\\.vbs调用:MakeReplace
对于('dir“%3”/s/b/a-d/on')中的/f“tokens=*”%%a,请执行以下操作(
对于(`Findstr/mic:'%1”“%%a`)中的/f“usebackq”%%b,请执行以下操作(
echo(&echo将文件%%~nxa中的“%~1”替换为“%~2”
%tmp%
如果存在%tmp%move/Y%tmp%“%%~dpnxa”>nul
)
)
删除%temp%\\\.vbs
退出/b
:MakeReplace
>%temp%\\.vbs与Wscript的回显
>>%temp%\\.vbs回显集参数=.arguments
>>%temp%\\.vbs echo.StdOut.Write_
>>%临时%\\ vbs回显替换(.StdIn.ReadAll,args(0),args(1),1,-1,1)
>>%temp%\\.vbs回显结束

答案是使用AssemblyMetadataAttribute

但为了让它发挥作用,我们需要团队合并此PR并让NuGet实施它:


如果有必要,我愿意提供一个自定义的nuget.exe版本和修复程序。这是我自己使用的

我不知道nuget是开源的……谢谢。我会查看PR并了解我需要知道的:)