autorest icon indicating copy to clipboard operation
autorest copied to clipboard

AutoRest NuGet package should be marked with developmentDependency

Open gitfool opened this issue 10 years ago • 4 comments

Scenario: Given a C# 'proxy' library for a REST service that is auto-generated from a Swagger.json file using AutoRest executed via a T4 template.

The proxy project installed AutoRest via NuGet and has the following NuGet packages:

<packages>
  <package id="autorest" version="0.15.0" targetFramework="net451" />
  <package id="Microsoft.Rest.ClientRuntime" version="2.1.0" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net451" />
</packages>

Problem: By default the AutoRest package dependency is propagated unnecessarily when the proxy project is itself packaged up and published to NuGet.

This can be solved manually by changing the NuGet packages manifest to be:

<packages>
  <package id="autorest" version="0.15.0" targetFramework="net451" developmentDependency="true" />
  <package id="Microsoft.Rest.ClientRuntime" version="2.1.0" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net451" />
</packages>

However, this will need to be done every time the AutoRest package is updated in the proxy project.

Solution: Assuming NuGet 2.8 or newer, the AutoRest package itself should be marked as a development dependency, then the above change will happen automatically for all consumers of the AutoRest package.

Specifically, the AutoRest NuSpec file needs to specify the following:

<?xml version="1.0"?>
<package>
  <metadata minClientVersion="2.8">
    <developmentDependency>true</developmentDependency>
  </metadata>
</package>

References:

gitfool avatar May 08 '16 23:05 gitfool

@gitfool Good idea, thanks for all the good information! We'll include this in our next release.

tbombach avatar May 09 '16 21:05 tbombach

@tbombach Looks like this didn't make the 0.16.0 release? No problem, just making sure. :wink:

gitfool avatar May 13 '16 01:05 gitfool

@gitfool No, didn't make the 0.16.0 release. It's scheduled for 0.17.0 though

tbombach avatar May 17 '16 23:05 tbombach

@gitfool, I'm going to have to defer this until after the dotnet-cli releases the next version, since currently we generate all this with project.json right now, and I'm not going to change that stuff until we move back to .csproj (and assumably .nuspec files?) ...

fearthecowboy avatar Oct 28 '16 18:10 fearthecowboy