Skip to content

Use dotnet to push packages to nuget #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Tools/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
nuget.exe
nunit.*
vswhere/
csharpasyncgenerator.commandline/
Expand Down
8 changes: 0 additions & 8 deletions build-common/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@
<property name="tools.dir" value="${root.dir}/Tools"/>
</target>

<target name="common.download-nuget" depends="common.init">
<get
src="https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
dest="${tools.dir}/nuget.exe"
usetimestamp="true"
/>
</target>

<target name="common.tools-restore" depends="common.init">
<exec workingdir="${root.dir}/Tools" program="dotnet" verbose="true">
<arg line="restore ./packages.csproj --packages ." />
Expand Down
14 changes: 6 additions & 8 deletions default.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
</target>

<target name="nuget.set-properties">
<property name="nuget.nupackages.relative-dir" value="nuget_gallery" />
<property name="nuget.nupackages.dir" value="${build.dir}/${nuget.nupackages.relative-dir}" />
<property name="nuget.nupackages.dir" value="${build.dir}/nuget_gallery" />
<property name="nuget.nupackages.pushbatfile" value="${nuget.nupackages.dir}/NuGetPush.bat" />
</target>

Expand Down Expand Up @@ -313,11 +312,9 @@

</target>

<target name="nugetpushbat" depends="init binaries common.download-nuget nuget.set-properties"
<target name="nugetpushbat" depends="init binaries nuget.set-properties"
description="Creates files for the release on nuget gallery.">

<copy file="${tools.dir}/NuGet.exe" todir="${nuget.nupackages.dir}"/>

<echo message="rem In order to use this bat you have to be sure you have executed 'nuget SetApiKey' ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="false"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment 'nuget SetApiKey' should also be updated accordingly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no dotnet nuget SetApiKey.

As a workaround you could use nuget.exe setApiKey (or set the values manually in your nuget.config and then use dotnet nuget push. dotnet.exe should read the nuget.config and use the api keys found there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to change as you see fit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems workaround doesn't work for everyone (linux specific issue?)

Well have nothing to add - if you see no possible issues. Then fine. May be just add link to nuget.exe (https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) in this comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need to explain more. Anyway, only most active contributors do the push currently. I guess we will all find what to do in case of troubles.

<foreach item="File" property="filename">
<in>
Expand All @@ -326,12 +323,12 @@
</items>
</in>
<do>
<echo message="nuget push -source https://api.nuget.org/v3/index.json ${path::get-file-name(filename)} ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="true"/>
<echo message="dotnet nuget push -s https://api.nuget.org/v3/index.json ${path::get-file-name(filename)} ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="true"/>
</do>
</foreach>
</target>

<target name="nugetpush" depends="init binaries common.download-nuget nuget.set-properties"
<target name="nugetpush" depends="init binaries nuget.set-properties"
description="Push packages on nuget gallery.">
<!-- In order to use this task you have to be sure you have executed 'nuget SetApiKey' -->
<foreach item="File" property="filename">
Expand All @@ -341,7 +338,8 @@
</items>
</in>
<do>
<exec basedir="${tools.dir}" workingdir="${nuget.nupackages.dir}" program="NuGet.exe">
<exec basedir="${tools.dir}" workingdir="${nuget.nupackages.dir}" program="dotnet">
<arg value="nuget" />
<arg value="push" />
<arg value="${filename}" />
</exec>
Expand Down