Reputation: 1725
I'm trying to automate the building of a nuget package, but I have a few issues with example values, namely things like License URL, Icon URL, etc. I want to be able to replace the project URL, Tags, and Summary, while completely removing the License URL and the Icon URL... I'm automating this from CMD, and I can't find any attributes for these values that I can stick in the Assembly Info... How do I do this?
Upvotes: 1
Views: 153
Reputation: 1871
The answer is to use AssemblyMetadataAttribute.
But for it to work, we need the team to merge this PR and get NuGet to implement it: https://github.com/NuGet/NuGet.Client/pull/622
If necessary, I'm willing to provide a custom build of nuget.exe with the fix. It's what I'm using myself
Upvotes: 1
Reputation: 1725
I found out that it's not possible to set it this way, so I just had to use nuget spec
then change the file using batch operations. For future reference, please see below for the relevant Batch:
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
Upvotes: 0