Skip to content

Commit

Permalink
Add PackAndMove build target
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdecock committed Nov 15, 2024
1 parent 8e2910e commit 2e089de
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflow-gen/workflow-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<RootNamespace>workflow_gen</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<DuendePackageDir Condition=" '$(DuendePackageDir)' == '' ">$(MSBuildThisFileDirectory)packages</DuendePackageDir>
</PropertyGroup>

<Target Name="PackAndMove" Condition="'$(IsPackable)' == 'true'">
<Exec Command="dotnet pack --configuration Release --output $(DuendePackageDir)" />
</Target>

</Project>
4 changes: 4 additions & 0 deletions access-token-management/samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="../../samples.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Duende.AccessTokenManagement</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Expand Down
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory contains internal documentation for the foss repository, with notes on the
build process and tooling. See
[here](https://github.com/DuendeSoftware/docs.duendesoftware.com/) for user documentation.

## Topics
### NuGet
- [Local Packages](nuget/local.md)
52 changes: 52 additions & 0 deletions docs/nuget/local.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Building Packages Locally

## PackAndMove
Each project in this repository includes a `PackAndMove` target (see
Directory.Build.targets), which will compile and package the project as a NuGet package
and then copy the output to a configurable directory (\packages by default). You can
`PackAndMove` a single project by changing to its directory and running `dotnet build
-t:PackAndMove`, or you can run the same command from the root of the repository to pack
and move all packages in the repo.

The intent of PackAndMove is to be a convenience when building packages locally. By
default, `dotnet pack` scatters its output into many nested subdirectories like
`\identity-model\src\IdentityModel\bin\Debug\`. Moving all the packages into a single
location makes it quick to access them and allows you to easily consume the package from a
test or sample project.

### Configuring Output Dir for PackAndMove
To configure the output directory, either set the `DuendePackageDir` environment variable,
or pass the `DuendePackageDir` property to the build command:

#### Environment Variable
```ps
# powershell
$Env:DuendePackageDir=C:\packages
dotnet build -t:PackAndMove
```

#### Command Line Argument
```
dotnet build -t:PackAndMove -p:DuendePackageDir=C:\packages
```


## Consuming Local Packages
If you want to try out local builds of your packages, you can add a directory (such as the
directory you use for PackAndMove) as a package source to NuGet. To do so, add the feed to
your NuGet.Config file. You can do this for your entire user account or on a per-project
basis. On windows, you personal config file is located at %appdata%\NuGet\NuGet.Config.
More details from Microsoft's docs
[here](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior).

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Local Builds" value="C:\packages" />
<!-- Other sources omitted -->
</packageSources>
</configuration>
```

You can also set this configuration via most IDEs.
4 changes: 4 additions & 0 deletions identity-model-oidc-client/clients/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="../../samples.props" />
</Project>
4 changes: 4 additions & 0 deletions identity-model-oidc-client/samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="../../samples.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<PublishTrimmed>true</PublishTrimmed>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>NU1507</NoWarn>
<NoWarn>$(NoWarn);NU1507</NoWarn>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions samples.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<NoWarn>$(NoWarn);1591;NU1507</NoWarn>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> -->
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions src.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<Copyright>Duende Software</Copyright>
<DebugType>full</DebugType>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
<NoWarn>CS1591,NU1507</NoWarn>
<NoWarn>$(NoWarn);CS1591,NU1507</NoWarn>
<IsTestProject>false</IsTestProject>
<IsPackable>true</IsPackable>
<IsTrimmable Condition="'$(TargetFramework)' != 'netstandard2.0'">true</IsTrimmable>
Expand Down
3 changes: 1 addition & 2 deletions test.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<DebugType>full</DebugType>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>preview</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<NoWarn>NU1507</NoWarn>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 2e089de

Please sign in to comment.