Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion doc/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\Directory.Packages.props" />
<ItemGroup>
<!-- Reference latest stable version of MDS and AKV provider -->
Comment thread
paulmedynski marked this conversation as resolved.
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.2" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.4" />
<PackageVersion Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="6.1.2" />
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions doc/apps/AzureAuthentication/AzureAuthentication.csproj
Comment thread
paulmedynski marked this conversation as resolved.
Comment thread
paulmedynski marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net481;net10.0</TargetFrameworks>
Comment thread
paulmedynski marked this conversation as resolved.
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<!-- SqlClient Packages -->
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" />
<!--
We include the AKV Provider to ensure there are no transitive dependency conflicts. It is
instantiated to ensure its assembly isn't elided, but we don't actually use it.
-->
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />

<!-- Include the Azure package if a version for it was specified. -->
<PackageReference
Include="Microsoft.Data.SqlClient.Extensions.Azure"
Condition="'$(AzureVersion)' != ''" />
</ItemGroup>

<!-- Other Packages -->
<ItemGroup>
<PackageReference Include="Azure.Identity" />
<PackageReference Include="System.CommandLine" />
</ItemGroup>

<!-- Generate code with the SqlClient package versions. -->
Comment thread
paulmedynski marked this conversation as resolved.
<Import Project="GeneratePackageVersions.targets" />

</Project>
10 changes: 10 additions & 0 deletions doc/apps/AzureAuthentication/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- We purposely do not include any parent Directory.Build.props files. -->

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

</Project>
32 changes: 32 additions & 0 deletions doc/apps/AzureAuthentication/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- We purposely do not include any parent Directory.Packages.props files. -->

<PropertyGroup>
<!-- Use SqlClient 6.1.4 if no version was specified. -->
<SqlClientVersion>6.1.4</SqlClientVersion>

<!-- Use AKV Provider 6.1.2 if no version was specified. -->
<AkvProviderVersion>6.1.2</AkvProviderVersion>
</PropertyGroup>

<!-- SqlClient Packages -->
<ItemGroup>
<PackageVersion Include="Microsoft.Data.SqlClient" Version="$(SqlClientVersion)" />
<PackageVersion Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="$(AkvProviderVersion)" />

<!-- Declare a version for the Azure package if one was specified. -->
<PackageVersion
Include="Microsoft.Data.SqlClient.Extensions.Azure"
Version="$(AzureVersion)"
Condition="'$(AzureVersion)' != ''" />
</ItemGroup>

<!-- Other Packages -->
<ItemGroup>
<PackageVersion Include="Azure.Identity" Version="1.17.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.3" />
</ItemGroup>

</Project>
111 changes: 111 additions & 0 deletions doc/apps/AzureAuthentication/GeneratePackageVersions.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Comment thread
paulmedynski marked this conversation as resolved.

<!-- Inline task that generates a static class whose properties expose package versions. -->
<UsingTask TaskName="GeneratePackageVersionsClass"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Packages ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<Versions ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<Defaults ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<Namespace ParameterType="System.String" Required="true" />
<OutputFile ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
// Build a lookup from PackageVersion items (used by Central Package Management).
var versionMap = new System.Collections.Generic.Dictionary<string, string>(
System.StringComparer.OrdinalIgnoreCase);
foreach (var v in Versions)
versionMap[v.ItemSpec] = v.GetMetadata("Version");

var sb = new System.Text.StringBuilder();
sb.AppendLine("// <auto-generated/>");
sb.AppendLine();
sb.AppendLine($"namespace {Namespace};");
sb.AppendLine();
sb.AppendLine("internal static class PackageVersions");
sb.AppendLine("{");
// Track which packages we've already emitted.
var emitted = new System.Collections.Generic.HashSet<string>(
System.StringComparer.OrdinalIgnoreCase);

foreach (var pkg in Packages)
{
var id = pkg.ItemSpec;

// Prefer Version metadata on the PackageReference itself; fall back to the
// PackageVersion item (CPM) if not present.
var version = pkg.GetMetadata("Version");
if (string.IsNullOrEmpty(version))
versionMap.TryGetValue(id, out version);
if (string.IsNullOrEmpty(version))
continue;

var propertyName = id.Replace(".", "");
sb.AppendLine($" public static string {propertyName} => \"{version}\";");
emitted.Add(id);
}

// Emit entries for any default packages that weren't already referenced.
if (Defaults != null)
{
foreach (var def in Defaults)
{
var id = def.ItemSpec;
if (emitted.Contains(id))
continue;
var fallback = def.GetMetadata("DefaultVersion");
if (string.IsNullOrEmpty(fallback))
fallback = "None";
var propertyName = id.Replace(".", "");
sb.AppendLine($" public static string {propertyName} => \"{fallback}\";");
}
}
sb.AppendLine("}");

var dir = System.IO.Path.GetDirectoryName(OutputFile);
if (!string.IsNullOrEmpty(dir) && !System.IO.Directory.Exists(dir))
System.IO.Directory.CreateDirectory(dir);
System.IO.File.WriteAllText(OutputFile, sb.ToString());
]]>
</Code>
</Task>
</UsingTask>

<!--
Generate PackageVersions.g.cs before compilation. The target passes both
PackageReference and PackageVersion items so it works with Central Package
Management (where Version metadata lives on PackageVersion, not PackageReference).
-->
<Target Name="GeneratePackageVersionsFile"
BeforeTargets="CoreCompile"
DependsOnTargets="CollectPackageReferences"
Inputs="$(MSBuildProjectFullPath);$(MSBuildAllProjects)"
Outputs="$(IntermediateOutputPath)PackageVersions.g.cs">
<PropertyGroup>
<_PackageVersionsFile>$(IntermediateOutputPath)PackageVersions.g.cs</_PackageVersionsFile>
</PropertyGroup>

<!-- Delete the previously generated file so changes are always picked up. -->
<Delete Files="$(_PackageVersionsFile)" Condition="Exists('$(_PackageVersionsFile)')" />

<ItemGroup>
<_DefaultPackageVersionEntry Include="Microsoft.Data.SqlClient.Extensions.Azure" DefaultVersion="None" />
</ItemGroup>

<GeneratePackageVersionsClass
Packages="@(PackageReference)"
Versions="@(PackageVersion)"
Defaults="@(_DefaultPackageVersionEntry)"
Namespace="$(RootNamespace)"
OutputFile="$(_PackageVersionsFile)" />

<ItemGroup>
<Compile Include="$(_PackageVersionsFile)" />
<FileWrites Include="$(_PackageVersionsFile)" />
</ItemGroup>
</Target>

</Project>
13 changes: 13 additions & 0 deletions doc/apps/AzureAuthentication/NuGet.config
Comment thread
paulmedynski marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />

<!--
Add a local directory as a package source. This lets us build against packages that haven't
been published yet.
-->
<add key="local" value="packages/" />
</packageSources>
</configuration>
Loading
Loading