Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ jobs:
uses: actions/setup-dotnet@v5.2.0
with:
global-json-file: global.json

- name: Restore dotnet tools
shell: bash
run: dotnet tool restore

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
17 changes: 12 additions & 5 deletions BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@ on operating systems that do not support .NET Framework. As such, it is not nece

### Miscellaneous

**PowerShell** is required to run several miscellaneous tasks as part of building and packaging. On
Windows systems, either the built-in `powershell.exe` will be used, or if installed, the modern
`pwsh` will be used. On Linux and macOS systems, the `pwsh` command is required to be in the `$PATH`
environment variable. For specific instructions see: [Install
PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell)
**PowerShell** is included as a .NET local tool in this repository. Running `dotnet tool restore`
(see below) will make it available via `dotnet tool run pwsh -- <args>`. Note that `pwsh` is not
added to PATH — it must be invoked through `dotnet tool run`. Build targets handle this
automatically; manual invocation is only needed for ad-hoc scripting.

The **NuGet** binary is optional for inspection and feed-management workflows, but build and packaging flows in this
repository are run through `dotnet build` against `build.proj`.

### .NET Tools

This repository uses .NET local tools (e.g. PowerShell) that must be restored before building. Run the following from the repository root:

```bash
dotnet tool restore
```

## Developer Workflow

Once you've cloned the repository and made your changes to the codebase, it is time to build, test, and optionally
Expand Down
7 changes: 7 additions & 0 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"apicompat"
],
"rollForward": false
},
"powershell": {
"version": "7.6.0",
"commands": [
"pwsh"
],
"rollForward": false
Comment thread
mdaigle marked this conversation as resolved.
}
}
}
3 changes: 3 additions & 0 deletions eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ jobs:
# Install the .NET SDK.
- template: /eng/pipelines/steps/install-dotnet.yml@self

# Restore dotnet CLI tools (e.g. pwsh, apicompat) before building.
- template: /eng/pipelines/steps/restore-dotnet-tools.yml@self

# When we're performing a Debug build, we still want to try _compiling_ the
# code in Release mode to ensure downstream pipelines don't encounter
# compilation errors. We won't use the Release artifacts for anything else
Expand Down
3 changes: 3 additions & 0 deletions eng/pipelines/common/templates/jobs/ci-run-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ jobs:
${{ else }}:
runtimes: [8.x, 9.x]

# Restore dotnet CLI tools (e.g. pwsh, apicompat) before building.
- template: /eng/pipelines/steps/restore-dotnet-tools.yml@self

- ${{ if ne(parameters.prebuildSteps, '') }}:
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration

Expand Down
14 changes: 14 additions & 0 deletions eng/pipelines/steps/restore-dotnet-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#################################################################################
# Licensed to the .NET Foundation under one or more agreements. #
# The .NET Foundation licenses this file to you under the MIT license. #
# See the LICENSE file in the project root for more information. #
#################################################################################

# Restores dotnet CLI tools defined in dotnet-tools.json.
# This step should be invoked after install-dotnet.yml and before any build
# steps that depend on the restored tools (e.g. pwsh, apicompat).

steps:
- script: dotnet tool restore
displayName: Restore .NET Tools
workingDirectory: $(Build.SourcesDirectory)
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,35 @@
<OutputPath>$(ArtifactPath)$(AssemblyName).ref/$(ReferenceType)-$(Configuration)/</OutputPath>
</PropertyGroup>


<!-- Trim Docs for IntelliSense ====================================== -->
<!--
It has been determined that including the remarks section in IntelliSense docs looks bad in
Visual Studio. So, before we generate the ref binaries, we trim off the remarks tags. We leave
them in the xml files, though, because those are the source for the docs site, which needs to
have the full documentation.
-->
<!-- Verifies that dotnet local tools have been restored (pwsh is required for doc trimming). -->
<Target Name="_CheckPwshToolRestored">
<Exec Command="dotnet tool run pwsh -- -Version"
WorkingDirectory="$(RepoRoot)"
ConsoleToMsBuild="true"
IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="_PwshExitCode" />
</Exec>
Comment thread
paulmedynski marked this conversation as resolved.
<Error Condition="'$(_PwshExitCode)' != '0'"
Text="The 'pwsh' dotnet local tool is not available. Run 'dotnet tool restore' from the repository root before building." />
Comment thread
mdaigle marked this conversation as resolved.
</Target>

<!-- This target runs after Build, and trims XML documentation generated in the $(OutputPath) of the project where this target is included.-->
<Target Name="TrimDocsForIntelliSense"
AfterTargets="Build"
DependsOnTargets="_CheckPwshToolRestored"
Condition="'$(IsCrossTargetingBuild)' != 'true' AND '$(GenerateDocumentationFile)' == 'true'">

<PropertyGroup>
<PowerShellCommand Condition="'$(OS)' == 'Windows_NT'">powershell.exe</PowerShellCommand>
<PowerShellCommand Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellCommand>
<PowerShellCommand>
$(PowerShellCommand)
dotnet tool run pwsh --
Comment thread
mdaigle marked this conversation as resolved.
-NonInteractive
-ExecutionPolicy Unrestricted
-Command "$(RepoRoot)tools\intellisense\TrimDocs.ps1 -inputFile '$(DocumentationFile)' -outputFile '$(DocumentationFile)'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public void SimpleFillTest()

// TODO Synapse: Remove Northwind dependency by creating required tables in setup.
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
// https://github.com/dotnet/SqlClient/issues/4135
[Trait("Category", "flaky")]
public void FillShouldAllowRetryLogicProviderToBeInvoked()
{
int maxRetries = 3;
Expand Down
27 changes: 17 additions & 10 deletions tools/targets/CompareMdsRefAssemblies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,24 @@
Text="BaselinePackageVersion is required. Specify the published MDS NuGet package version to compare against, e.g.: /p:BaselinePackageVersion=6.1.4" />
</Target>

<!-- ================================================================== -->
<!-- _CheckApiCompatToolRestored -->
<!-- ================================================================== -->
<Target Name="_CheckApiCompatToolRestored">
<Exec Command="dotnet tool run apicompat -- --version"
WorkingDirectory="$(RepoRoot)"
ConsoleToMsBuild="true"
IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="_ApiCompatExitCode" />
</Exec>
Comment thread
paulmedynski marked this conversation as resolved.
<Error Condition="'$(_ApiCompatExitCode)' != '0'"
Text="The 'apicompat' dotnet local tool is not available. Run 'dotnet tool restore' from the repository root before running this target." />
</Target>

<!-- ================================================================== -->
<!-- _DownloadBaselinePackage -->
<!-- ================================================================== -->
<Target Name="_DownloadBaselinePackage" DependsOnTargets="_ValidateBaselineVersion;_SetApiCompatProperties">
<Target Name="_DownloadBaselinePackage" DependsOnTargets="_ValidateBaselineVersion;_CheckApiCompatToolRestored;_SetApiCompatProperties">
<!-- Skip download if already extracted -->
<Message
Condition="Exists('$(BaselineExtractDir)')"
Expand Down Expand Up @@ -90,13 +104,6 @@
Text="Baseline ref assemblies available at $(BaselineExtractDir)ref\" />
</Target>

<!-- ================================================================== -->
<!-- _RestoreTools -->
<!-- ================================================================== -->
<Target Name="_RestoreTools" DependsOnTargets="_SetApiCompatProperties">
<Exec Command="dotnet tool restore" WorkingDirectory="$(RepoRoot)" />
</Target>

<!-- ================================================================== -->
<!-- _BuildRefProject -->
<!-- ================================================================== -->
Expand All @@ -111,7 +118,7 @@
<!-- _RunRefApiCompat -->
<!-- ================================================================== -->
<Target Name="_RunRefApiCompat"
DependsOnTargets="_DownloadBaselinePackage;_RestoreTools;_BuildRefProject">
DependsOnTargets="_DownloadBaselinePackage;_BuildRefProject">
Comment thread
paulmedynski marked this conversation as resolved.

Comment thread
mdaigle marked this conversation as resolved.
<!--
For each TFM, compare the consolidated ref output against the baseline
Expand All @@ -134,7 +141,7 @@
Text="--- Comparing %(_RefTfm.Identity) ref vs baseline $(BaselinePackageVersion) ---" />

<Exec
Command="dotnet apicompat -l &quot;$(BaselineExtractDir)ref/%(_RefTfm.Identity)/Microsoft.Data.SqlClient.dll&quot; -r &quot;$(RefOutputDir)%(_RefTfm.Identity)/Microsoft.Data.SqlClient.dll&quot; --strict-mode &gt; &quot;$(ApiCompatResultsDir)%(_RefTfm.Identity).txt&quot; 2&gt;&amp;1"
Command="dotnet tool run apicompat -- -l &quot;$(BaselineExtractDir)ref/%(_RefTfm.Identity)/Microsoft.Data.SqlClient.dll&quot; -r &quot;$(RefOutputDir)%(_RefTfm.Identity)/Microsoft.Data.SqlClient.dll&quot; --strict-mode &gt; &quot;$(ApiCompatResultsDir)%(_RefTfm.Identity).txt&quot; 2&gt;&amp;1"
WorkingDirectory="$(RepoRoot)"
ContinueOnError="ErrorAndContinue" />

Expand Down
Loading