1

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

4

2 回答 2

1

答案是使用 AssemblyMetadataAttribute。

但要让它发挥作用,我们需要团队合并这个 PR 并让 NuGet 来实现它:https ://github.com/NuGet/NuGet.Client/pull/622

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

于 2016-06-15T04:07:25.603 回答
0

我发现这样设置是不可能的,所以我只需要使用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
于 2016-06-14T18:32:12.087 回答