Skip to content

Commit 002de08

Browse files
Merge pull request #183 from PublicApiGenerator/package-source
Support for package-source
2 parents 5697b62 + 1fc2bf1 commit 002de08

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ Generate public API for NServiceBus 7.1.4 for runtime framework `netcoreapp2.2`
159159
generate-public-api --target-frameworks netcoreapp2.2;net452 --package NServiceBus --package-version 7.1.4 --assembly NServiceBus.Core.dll
160160
```
161161

162+
Generate a public API for NServiceBus release available on myget
163+
164+
```
165+
generate-public-api --target-frameworks netcoreapp2.2;net452 --package NServiceBus --package-version 7.1.4 --assembly NServiceBus.Core.dll --package-source https://www.myget.org/F/particular/api/v3/index.json
166+
```
167+
162168
### Command line arguments
163169

164170
```
@@ -196,6 +202,12 @@ A nuget package version or floating versions as specified by https://docs.micros
196202
- 8.0
197203
- 8.0-*
198204

205+
```
206+
--package-source Source
207+
```
208+
209+
Allows specifying one or multiple package sources to look for packages.
210+
199211
```
200212
--assembly Assembly.dll
201213
```

src/PublicApiGenerator.Tool/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace PublicApiGenerator.Tool
22
{
33
using System;
4+
using System.Collections.Generic;
45
using System.Diagnostics;
56
using System.IO;
67
using System.Linq;
@@ -22,13 +23,14 @@ public static class Program
2223
/// <param name="projectPath">The path to the csproj that should be used to build the public API.</param>
2324
/// <param name="package">The package name from which a public API should be created. The tool assumes the package name equals the assembly name. If the assembly name is different specify <paramref name="assembly"/></param>
2425
/// <param name="packageVersion">The version of the package defined in <paramref name="package"/> to be used.</param>
26+
/// <param name="packageSource">Package source or feed to use (multiple allowed).</param>
2527
/// <param name="generatorVersion">The version of the PublicApiGenerator package to use.</param>
2628
/// <param name="workingDirectory">The working directory to be used for temporary work artifacts. A temporary directory will be created inside the working directory and deleted once the process is done. If no working directory is specified the users temp directory is used.</param>
2729
/// <param name="outputDirectory">The output directory where the generated public APIs should be moved.</param>
2830
/// <param name="verbose"></param>
2931
/// <param name="leaveArtifacts"></param>
3032
/// <returns></returns>
31-
static int Main(string targetFrameworks, string? assembly = null, string? projectPath = null, string? package = null, string? packageVersion = null, string? generatorVersion = null, string? workingDirectory = null, string? outputDirectory = null, bool verbose = false, bool leaveArtifacts = false)
33+
static int Main(string targetFrameworks, string? assembly = null, string? projectPath = null, string? package = null, string? packageVersion = null, ICollection<string>? packageSource = null, string? generatorVersion = null, string? workingDirectory = null, string? outputDirectory = null, bool verbose = false, bool leaveArtifacts = false)
3234
{
3335
var logError = Console.Error;
3436
var logVerbose = verbose ? Console.Error : TextWriter.Null;
@@ -55,7 +57,7 @@ static int Main(string targetFrameworks, string? assembly = null, string? projec
5557
generatorVersion = $"{Assembly.GetEntryAssembly().GetName().Version.Major}.*";
5658
}
5759

58-
var project = CreateProject(targetFrameworks, projectPath, package, packageVersion, generatorVersion!);
60+
var project = CreateProject(targetFrameworks, projectPath, package, packageVersion, packageSource, generatorVersion!);
5961

6062
SaveProject(workingArea, project, logVerbose);
6163

@@ -237,15 +239,20 @@ private static string GetManifestResourceText(this Type type, string name,
237239

238240
private static XElement CreateProject(string targetFrameworks,
239241
string? project,
240-
string? package, string? packageVersion,
242+
string? package,
243+
string? packageVersion,
244+
ICollection<string>? packageSource,
241245
string generatorVersion)
242246
{
243247
return
244248
new XElement("Project", new XAttribute("Sdk", "Microsoft.NET.Sdk"),
245249
new XElement("PropertyGroup",
246250
new XElement("OutputType", "Exe"),
247251
new XElement("TargetFrameworks", targetFrameworks),
248-
new XElement("CopyLocalLockFileAssemblies", "true")),
252+
new XElement("CopyLocalLockFileAssemblies", "true"),
253+
packageSource?.Count > 0
254+
? new XElement("RestoreAdditionalProjectSources", string.Join(";", packageSource))
255+
: null),
249256
new XElement("ItemGroup",
250257
PackageReference(nameof(PublicApiGenerator), generatorVersion),
251258
!string.IsNullOrEmpty(package) ? PackageReference(package!, packageVersion!) : null,

0 commit comments

Comments
 (0)