Merge pull request #401 from microsoft/chbeck/ghcodespaces
Upgraded infrastructure + onboard to GitHub Codespaces + upgraded dependencies
This commit is contained in:
Коммит
cf341f0c84
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"nbgv": {
|
||||
"version": "3.6.143",
|
||||
"commands": [
|
||||
"nbgv"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "powerbi-powershell in Codespaces",
|
||||
"image": "mcr.microsoft.com/dotnet/sdk:8.0",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {
|
||||
"version": "2"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/powershell:1": {
|
||||
"version": "latest"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/common-utils:2": {},
|
||||
"ghcr.io/devcontainers/features/dotnet:2": {
|
||||
"version": "none",
|
||||
"dotnetRuntimeVersions": "7.0",
|
||||
"aspNetCoreRuntimeVersions": "7.0"
|
||||
}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"GitHub.copilot",
|
||||
"GitHub.copilot-chat",
|
||||
"GitHub.vscode-github-actions",
|
||||
"ms-dotnettools.vscode-dotnet-runtime",
|
||||
"ms-dotnettools.csdevkit",
|
||||
"ms-dotnetools.csharp",
|
||||
"ms-vscode.powershell",
|
||||
"ms-dotnettools.vscodeintellicode-csharp",
|
||||
"esbenp.prettier-vscode",
|
||||
"github.github-vscode-theme",
|
||||
"github.vscode-pull-request-github",
|
||||
"github.vscode-codeql",
|
||||
"ms-cst-e.vscode-devskim"
|
||||
]
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "dotnet restore dirs.proj",
|
||||
"hostRequirements": {
|
||||
"memory": "8gb",
|
||||
"cpus": 4
|
||||
},
|
||||
"remoteEnv": {
|
||||
"DOTNET_MULTILEVEL_LOOKUP": "0",
|
||||
"TARGET": "net8.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
name: Upload Package to GitHub Packages
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: [self-hosted, 1ES.Pool=powerbi-powershell-pool]
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Need for history to be able to determine version number
|
||||
|
||||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
#dotnet-version: '8.0.x' # SDK Version to use.
|
||||
global-json-file: 'global.json'
|
||||
source-url: https://nuget.pkg.github.com/microsoft/powerbi-powershell/index.json
|
||||
env:
|
||||
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
- name: Create the package
|
||||
run: dotnet pack --configuration Release dirs.proj
|
||||
|
||||
- name: Publish the package to GPR
|
||||
run: dotnet nuget push PkgOut/*.nupkg
|
|
@ -0,0 +1,58 @@
|
|||
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
|
||||
|
||||
name: PR Build
|
||||
run-name: Executing Build for ${{ github.actor }} on ${{ github.repository }} for branch ${{ github.ref }}
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
Build:
|
||||
runs-on: [self-hosted, 1ES.Pool=powerbi-powershell-pool]
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Need for history to be able to determine version number
|
||||
|
||||
- name: Disable StrongName
|
||||
shell: pwsh
|
||||
run: |
|
||||
scripts/DisableStrongName.ps1
|
||||
|
||||
- name: Setup .NET 8.x
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
# Semantic version range syntax or exact version of a dotnet version
|
||||
#dotnet-version: '8.x'
|
||||
global-json-file: 'global.json'
|
||||
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
# Look to see if there is a cache hit for the corresponding requirements file
|
||||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.*proj','**/*.props','**/*.targets','**/*.cs') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nuget
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore dirs.proj
|
||||
|
||||
- name: Build
|
||||
run: dotnet build --no-restore dirs.proj --property:GenerateFullPaths=true --verbosity normal
|
||||
|
||||
- name: Test
|
||||
run: dotnet test --no-build --no-restore --filter "TestCategory!=Interactive" --verbosity normal --logger trx --results-directory "TestResults" dirs.proj
|
||||
|
||||
- name: Publish Test Results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: TestResults
|
||||
path: TestResults
|
||||
if: ${{ always() }}
|
|
@ -291,4 +291,7 @@ __pycache__/
|
|||
*.binlog
|
||||
|
||||
# Package Build Output
|
||||
PkgOut/
|
||||
PkgOut/
|
||||
|
||||
# Mono\VSCode development
|
||||
.mono/
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"ms-vscode.powershell",
|
||||
"ms-dotnettools.csdevkit",
|
||||
"ms-dotnettools.vscodeintellicode-csharp",
|
||||
"GitHub.copilot",
|
||||
"GitHub.copilot-chat",
|
||||
"MS-CST-E.vscode-devskim",
|
||||
"ms-sarifvscode.sarif-viewer",
|
||||
"esbenp.prettier-vscode",
|
||||
"github.codespaces",
|
||||
"github.github-vscode-theme",
|
||||
"github.vscode-pull-request-github",
|
||||
"github.vscode-github-actions",
|
||||
"github.vscode-codeql"
|
||||
]
|
||||
}
|
|
@ -23,6 +23,19 @@
|
|||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
},
|
||||
{
|
||||
"type": "PowerShell",
|
||||
"request": "attach",
|
||||
"name": "PowerShell Attach to Host Process",
|
||||
"processId": "${command:PickPSHostProcess}",
|
||||
"runspaceId": 1
|
||||
},
|
||||
{
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"name": "PowerShell Interactive Session",
|
||||
"cwd": "${workspaceRoot}"
|
||||
}
|
||||
,]
|
||||
}
|
|
@ -4,6 +4,8 @@
|
|||
"**/.vs/": true,
|
||||
"**/bin/": true,
|
||||
"**/obj/": true,
|
||||
"TestResult/": true
|
||||
"TestResult/": true,
|
||||
".mono/": true,
|
||||
"powerbi-powershell.sln": true
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
// https://code.visualstudio.com/docs/editor/variables-reference
|
||||
// Example: https://github.com/PowerShell/vscode-powershell/blob/main/examples/.vscode/tasks.json
|
||||
"version": "2.0.0",
|
||||
"windows": {
|
||||
"options": {
|
||||
"shell": {
|
||||
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
||||
"executable": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
||||
"args": [
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
|
@ -38,12 +39,46 @@
|
|||
},
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build",
|
||||
"label": "Build via dotnet",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/dirs.proj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Build (Release) via dotnet",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"args": [
|
||||
"build",
|
||||
"-c",
|
||||
"Release",
|
||||
"${workspaceFolder}/dirs.proj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Build via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\Build.ps1'",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
"isDefault": false
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
@ -60,25 +95,49 @@
|
|||
// }
|
||||
// },
|
||||
{
|
||||
"label": "Clean",
|
||||
"label": "Clean via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\Build.ps1' -Clean -NoBuild",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Pack",
|
||||
"label": "Clean via dotnet",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"clean",
|
||||
"${workspaceFolder}/dirs.proj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Pack via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\Build.ps1' -Pack -Clean",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Restore",
|
||||
"label": "Pack (release build) via dotnet",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"pack",
|
||||
"${workspaceFolder}/dirs.proj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Restore via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\RestorePackages.ps1'",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "Test",
|
||||
"label": "Test via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\Test.ps1'",
|
||||
"group": "test",
|
||||
|
@ -89,7 +148,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"label": "PrepManualTesting",
|
||||
"label": "PrepManualTesting via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\PrepManualTesting.ps1' -Build -Force",
|
||||
"problemMatcher": "$msCompile",
|
||||
|
@ -102,7 +161,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"label": "DebugTest",
|
||||
"label": "DebugTest via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\DebugTest.ps1' -TestName '${selectedText}' -DirectoryName '${fileDirname}'",
|
||||
"problemMatcher": "$msCompile",
|
||||
|
@ -116,7 +175,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"label": "DebugTest (No Build)",
|
||||
"label": "DebugTest (No Build) via Shell",
|
||||
"type": "shell",
|
||||
"command": "& '${workspaceFolder}\\scripts\\DebugTest.ps1' -TestName '${selectedText}' -DirectoryName '${fileDirname}' -NoBuild",
|
||||
"problemMatcher": "$msCompile",
|
||||
|
|
|
@ -1,23 +1,38 @@
|
|||
# Contribute Code to PowerShell Cmdlets for Power BI
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Before releasing, it's important to test on both Windows and Linux\MacOS.
|
||||
> You can code either in Windows or GitHub Codspaces (or Dev Container on Windows), but it's recommended you test in the reverse environment.
|
||||
|
||||
## Developer Environment Requirements
|
||||
|
||||
* [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/)
|
||||
### GitHub Codespaces or Dev Container
|
||||
|
||||
Launch this code inside [GitHub Codespace](https://codespaces.new/microsoft/powerbi-powershell).
|
||||
|
||||
If you want to develop locally with a Dev Container, install this [VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers), follow steps to enable WSL (if not already enabled), when you launch VS Code it will ask if you want to open in Dev Container - click Yes to launch.
|
||||
|
||||
The [devcontainer.json](.devcontainer/devcontainer.json) defines the image.
|
||||
|
||||
For build and testing, `dotnet` [CLI tool](https://learn.microsoft.com/en-us/dotnet/core/tools/) is used instead of `msbuild` that is the default for Windows environments.
|
||||
|
||||
### Windows OS
|
||||
|
||||
* [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)
|
||||
* [.NET Core SDK](https://www.microsoft.com/net/learn/get-started/windows)
|
||||
* Version driven by [global.json](src/Common/Commands.Common/global.json)
|
||||
* Cmdlets are designed to use .NET Core 2.0 SDK with .NET Standard 2.0
|
||||
* Version driven by [global.json](src/global.json)
|
||||
* Cmdlets are designed to use .NET Core 8.0 SDK with .NET Standard 2.0
|
||||
* [Visual Studio Code](https://code.visualstudio.com/download)
|
||||
* Experimental and optional, still need Visual Studio installed
|
||||
* Install the following extensions:
|
||||
* [C#](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp): `code --install-extension ms-vscode.csharp`
|
||||
* [PowerShell](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell): `code --install-extension ms-vscode.PowerShell`
|
||||
|
||||
|
||||
> If you plan to build with Configuration=Release which Delay Signs the build output, call `.\scripts\DisableStrongName.ps1`.
|
||||
> If you plan to build with Configuration=Release which Delay Signs the build output, call `.\scripts\DisableStrongName.ps1` or just `DisableStrongName` if you called `init.ps1`.
|
||||
> Add the -Enable switch parameter to re-enable strong name verification once developing.
|
||||
|
||||
### Optional requirements (for testing)
|
||||
* [PowerShell Core (6.0.0)](https://github.com/powershell/powershell)
|
||||
* [PowerShell Core (7.0.0)](https://github.com/powershell/powershell)
|
||||
* Windows PowerShell v3 and up with .NET 4.7.1 or above
|
||||
|
||||
## Coding Style
|
||||
|
|
|
@ -6,7 +6,7 @@ Licensed under the MIT License.
|
|||
***********************************************************************************************
|
||||
-->
|
||||
<Project>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<MinimumMSBuildVersion>16.10</MinimumMSBuildVersion>
|
||||
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
|
||||
|
@ -15,8 +15,10 @@ Licensed under the MIT License.
|
|||
<RepoTargets>$(RepoRoot)build\</RepoTargets>
|
||||
<SourceRoot>$(RepoRoot)src\</SourceRoot>
|
||||
<ScriptsRoot>$(RepoRoot)scripts\</ScriptsRoot>
|
||||
<PowerShellExe Condition="'$(PowerShellExe)' == ''">$(WINDIR)\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellExe>
|
||||
<PowerShellExe Condition="!Exists('$(PowerShellExe)')">$(ProgramFiles)\PowerShell\7\pwsh.exe</PowerShellExe>
|
||||
<PowerShellExe Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(PowerShellExe)' == ''">/opt/microsoft/powershell/7/pwsh</PowerShellExe>
|
||||
<PowerShellExe Condition="$([MSBuild]::IsOSPlatform('Linux')) AND !Exists('$(PowerShellExe)')">/usr/share/powershell/pwsh</PowerShellExe>
|
||||
<PowerShellExe Condition="$([MSBuild]::IsOSPlatform('Windows')) AND '$(PowerShellExe)' == ''">$(ProgramFiles)\PowerShell\7\pwsh.exe</PowerShellExe>
|
||||
<PowerShellExe Condition="!Exists('$(PowerShellExe)')">pwsh</PowerShellExe> <!-- Default to pwsh in PATH -->
|
||||
<PowerShellCommonArgs>-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted</PowerShellCommonArgs>
|
||||
<LangName Condition="'$(LangName)' == ''">en-US</LangName>
|
||||
</PropertyGroup>
|
||||
|
@ -26,13 +28,6 @@ Licensed under the MIT License.
|
|||
<Company>Microsoft Corporation</Company>
|
||||
<Copyright>Copyright (c) Microsoft Corporation. All rights reserved.</Copyright>
|
||||
|
||||
<!-- Versioning -->
|
||||
<Version Condition="'$(Version)' == ''">1.2.0</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<PackageVersion>$(Version)</PackageVersion>
|
||||
<FileVersion>$(Version)</FileVersion>
|
||||
<InformationalVersion>$(Version)</InformationalVersion>
|
||||
|
||||
<!-- Packaging -->
|
||||
<Authors>Microsoft Corporation</Authors>
|
||||
<PackageLicenseUrl>https://github.com/Microsoft/powerbi-powershell/blob/master/LICENSE</PackageLicenseUrl>
|
||||
|
@ -48,15 +43,16 @@ Licensed under the MIT License.
|
|||
<PropertyGroup>
|
||||
<SlnGenLaunchVisualStudio>true</SlnGenLaunchVisualStudio>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SlnGen" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(RepoTargets)Microsoft.PowerBI.CodeSign.targets" Condition="'$(NoSignTarget)' != 'true' AND '$(MSBuildProjectFile)' != 'dirs.proj'"/>
|
||||
|
||||
<Import Project="$(RepoTargets)Microsoft.PowerBI.Build.targets" Condition="'$(NoBuildTarget)' != 'true' AND '$(MSBuildProjectFile)' != 'dirs.proj'"/>
|
||||
|
||||
<Import Project="$(RepoTargets)Microsoft.PowerBI.Packaging.targets" Condition="'$(NoPackageTarget)' != 'true' AND '$(MSBuildProjectFile)' != 'dirs.proj'"/>
|
||||
<!-- Versioning -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(RepoTargets)Microsoft.PowerBI.CodeSign.targets" Condition="'$(NoSignTarget)' != 'true' AND '$(MSBuildProjectFile)' != 'dirs.proj'" />
|
||||
<Import Project="$(RepoTargets)Microsoft.PowerBI.Build.targets" Condition="'$(NoBuildTarget)' != 'true' AND '$(MSBuildProjectFile)' != 'dirs.proj'" />
|
||||
<Import Project="$(RepoTargets)Microsoft.PowerBI.Packaging.targets" Condition="'$(NoPackageTarget)' != 'true' AND '$(MSBuildProjectFile)' != 'dirs.proj'" />
|
||||
</Project>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Sdk Name="Microsoft.Build.CentralPackageVersions" />
|
||||
|
||||
<!-- Ensure developers are using a minimun supported version of VS -->
|
||||
<Target Name="ValidateMinimumMsBuildVersion"
|
||||
|
@ -9,9 +8,18 @@
|
|||
<Error Text="Building this repository requires a minimun Visual Studio version of $(MinimumMSBuildVersion)" Condition="$(MSBuildVersion) < $(MinimumMSBuildVersion)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="ValidatePowerShellExeExists"
|
||||
<!-- Outdated check because we default for PWSH in PATH as a fallback -->
|
||||
<!-- <Target Name="ValidatePowerShellExeExists"
|
||||
BeforeTargets="Restore;$(BuildDependsOn);Build;$(RebuildDependsOn);Rebuild;$(CleanDependsOn);Clean"
|
||||
Condition=" '$(DesignTimeBuild)' != 'true' ">
|
||||
<Error Text="This repository requires either Windows PowerShell or PowerShell Core 7 to be installed (default location) to execute builds: $(PowerShellExe)" Condition="!Exists('$(PowerShellExe)')" />
|
||||
</Target>
|
||||
</Target> -->
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="PowerShellStandard.Library" PrivateAssets="all" />
|
||||
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.Identity.Client" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.Identity.Client.Broker" GeneratePathProperty="true" />
|
||||
<PackageReference Update="SlnGen" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<!-- Enable Central Package Management (CPS) - https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management -->
|
||||
<PropertyGroup>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<!-- <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled> -->
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageVersion Include="MSTest.TestAdapter" Version="3.2.1" />
|
||||
<PackageVersion Include="MSTest.TestFramework" Version="3.2.1" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageVersion Include="PowerShellStandard.Library" Version="7.0.0-preview.1" />
|
||||
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.1" />
|
||||
<PackageVersion Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.4.1" />
|
||||
<PackageVersion Include="Microsoft.WSMan.Management" Version="7.4.1" />
|
||||
<PackageVersion Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
|
||||
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.64.0" />
|
||||
<PackageVersion Include="Microsoft.Identity.Client" Version="4.64.0" />
|
||||
<PackageVersion Include="Microsoft.Identity.Client.Broker" Version="4.64.0" />
|
||||
<PackageVersion Include="Microsoft.PowerBI.Api" Version="2.14.0" />
|
||||
<PackageVersion Include="System.Runtime.Serialization.Json" Version="4.3.0" />
|
||||
<PackageVersion Include="Moq" Version="4.8.2" />
|
||||
<PackageVersion Include="platyPS" Version="0.9.0" />
|
||||
<PackageVersion Include="SlnGen" Version="2.2.30" />
|
||||
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||
<PackageReference Update="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Update="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Update="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Update="PowerShellStandard.Library" Version="7.0.0-preview.1" PrivateAssets="all" />
|
||||
<PackageReference Update="Microsoft.PowerShell.SDK" Version="7.1.1" />
|
||||
<PackageReference Update="Microsoft.PowerShell.Commands.Diagnostics" Version="7.1.1" />
|
||||
<PackageReference Update="Microsoft.WSMan.Management" Version="7.1.1" />
|
||||
<PackageReference Update="Microsoft.Rest.ClientRuntime" Version="2.3.11" />
|
||||
<PackageReference Update="System.Net.Http" Version="4.3.3" />
|
||||
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" Version="2.16.8" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.Identity.Client" Version="4.27.0" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.PowerBI.Api" Version="2.14.0" />
|
||||
<PackageReference Update="System.Runtime.Serialization.Json" Version="4.3.0" />
|
||||
<PackageReference Update="Moq" Version="4.8.2" />
|
||||
<PackageReference Update="platyPS" Version="0.9.0" />
|
||||
<PackageReference Update="SlnGen" Version="2.2.30" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
32
appveyor.yml
32
appveyor.yml
|
@ -1,32 +0,0 @@
|
|||
image: Visual Studio 2019
|
||||
|
||||
# Versioning
|
||||
version: '1.2.{build}'
|
||||
|
||||
dotnet_csproj:
|
||||
patch: true
|
||||
file: 'Directory.Build.props'
|
||||
version: '{version}'
|
||||
package_version: '{version}'
|
||||
assembly_version: '{version}'
|
||||
file_version: '{version}'
|
||||
informational_version: '{version}'
|
||||
|
||||
# Install
|
||||
install:
|
||||
- ps: scripts\DisableStrongName.ps1
|
||||
|
||||
# Build
|
||||
build_script:
|
||||
- ps: scripts\Build.ps1 -Configuration Release -Pack -AppVeyorLogger
|
||||
|
||||
before_build:
|
||||
- ps: scripts\RestorePackages.ps1
|
||||
|
||||
# Artifacts
|
||||
artifacts:
|
||||
- path: 'PkgOut\*.nupkg'
|
||||
|
||||
# Test
|
||||
test_script:
|
||||
- ps: scripts\Test.ps1 -Configuration Release -UploadResultsToAppVeyor
|
|
@ -15,6 +15,7 @@ Licensed under the MIT License.
|
|||
<ItemGroup>
|
||||
<MSALKnownPackageReferences Include="Microsoft.Identity.Client.Extensions.Msal" />
|
||||
<MSALKnownPackageReferences Include="Microsoft.Identity.Client" />
|
||||
<MSALKnownPackageReferences Include="Microsoft.Identity.Client.Broker" />
|
||||
</ItemGroup>
|
||||
|
||||
<FindInList CaseSensitive="false" List="@(PackageDependencies)" ItemSpecToFind="%(MSALKnownPackageReferences.Identity)">
|
||||
|
@ -27,15 +28,12 @@ Licensed under the MIT License.
|
|||
<ItemGroup Condition="'@(FoundMSALReferences)' != ''">
|
||||
<MsalPackageDefinitions Include="@(PackageDefinitions)" Condition="'%(Name)' == 'Microsoft.Identity.Client.Extensions.Msal'" />
|
||||
<MsalPackageDefinitions Include="@(PackageDefinitions)" Condition="'%(Name)' == 'Microsoft.Identity.Client'" />
|
||||
<MsalPackageDefinitions Include="@(PackageDefinitions)" Condition="'%(Name)' == 'Microsoft.Identity.Client.Broker'" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'@(MsalPackageDefinitions)' != ''">
|
||||
<MSALItemsToCopy Include="%(MsalPackageDefinitions.ResolvedPath)\lib\netcoreapp2.1\*.dll">
|
||||
<Destination>$(OutputPath)\MSAL\netcoreapp2.1</Destination>
|
||||
</MSALItemsToCopy>
|
||||
|
||||
<MSALItemsToCopy Include="%(MsalPackageDefinitions.ResolvedPath)\lib\net45\*.dll">
|
||||
<Destination>$(OutputPath)\MSAL\net45</Destination>
|
||||
<MSALItemsToCopy Include="%(MsalPackageDefinitions.ResolvedPath)\lib\netstandard2.0\*.dll">
|
||||
<Destination>$(OutputPath)\MSAL\netstandard2.0</Destination>
|
||||
</MSALItemsToCopy>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ Licensed under the MIT License.
|
|||
<ItemGroup>
|
||||
<FilteredResolveAssemblyReferenceResolvedFiles Include="@(_ResolveAssemblyReferenceResolvedFiles)" Condition="%(_ResolveAssemblyReferenceResolvedFiles.Filename) != 'netstandard'
|
||||
AND %(_ResolveAssemblyReferenceResolvedFiles.Filename) != 'mscorlib'
|
||||
AND %(_ResolveAssemblyReferenceResolvedFiles.Filename) != 'Microsoft.CSharp'
|
||||
AND %(_ResolveAssemblyReferenceResolvedFiles.Filename) != 'Microsoft.Identity.Client'
|
||||
AND %(_ResolveAssemblyReferenceResolvedFiles.Filename) != 'Microsoft.Identity.Client.Extensions.Msal'" />
|
||||
AND %(_ResolveAssemblyReferenceResolvedFiles.Filename) != 'Microsoft.CSharp'" />
|
||||
</ItemGroup>
|
||||
|
||||
<RemoveDuplicates Inputs="@(FilteredResolveAssemblyReferenceResolvedFiles)">
|
||||
|
@ -45,7 +43,7 @@ Licensed under the MIT License.
|
|||
</RemoveDuplicates>
|
||||
|
||||
<Message Text="Locating netstandard assembly" Importance="high" />
|
||||
<Exec ConsoleToMSBuild="true" Command="$(PowerShellExe) $(PowerShellCommonArgs) -Command "& { &'$(ScriptsRoot)GetNetstandardAssembly.ps1' } "">
|
||||
<Exec ConsoleToMSBuild="true" Command=""$(PowerShellExe)" $(PowerShellCommonArgs) -Command "& { & '$(ScriptsRoot)GetNetstandardAssembly.ps1' } "">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="NetStandardDllPath" />
|
||||
</Exec>
|
||||
|
||||
|
@ -136,7 +134,7 @@ Licensed under the MIT License.
|
|||
|
||||
<Target Name="UpdatePSManifest" DependsOnTargets="GetPSModuleSettings" Condition="'$(IsPackable)' == 'true'">
|
||||
|
||||
<Exec Command="$(PowerShellExe) $(PowerShellCommonArgs) -Command "& { &'$(ScriptsRoot)UpdatePSModuleManifest.ps1' -ModulePath '%(PSDFile.FullPath)' -TargetFramework '$(TargetFramework)' -Version '$(PackageVersion)' -ReleaseNotes '$(RepoRoot)ReleaseNotes.md'} "" />
|
||||
<Exec Command=""$(PowerShellExe)" $(PowerShellCommonArgs) -Command "& { &'$(ScriptsRoot)UpdatePSModuleManifest.ps1' -ModulePath '%(PSDFile.FullPath)' -TargetFramework '$(TargetFramework)' -Version '$(PackageVersion)' -ReleaseNotes '$(RepoRoot)ReleaseNotes.md'} "" />
|
||||
|
||||
</Target>
|
||||
|
||||
|
|
10
global.json
10
global.json
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "5.0.400"
|
||||
"version": "8.0.402",
|
||||
"rollForward": "latestFeature"
|
||||
},
|
||||
"msbuild-sdks": {
|
||||
"Microsoft.Build.Traversal": "3.0.23",
|
||||
"Microsoft.Build.CentralPackageVersions": "2.0.79",
|
||||
"Microsoft.Build.NoTargets": "3.0.4",
|
||||
"Microsoft.Build.Artifacts": "2.2.0"
|
||||
"Microsoft.Build.Traversal": "4.1.0",
|
||||
"Microsoft.Build.NoTargets": "3.7.56",
|
||||
"Microsoft.Build.Artifacts": "6.1.10"
|
||||
}
|
||||
}
|
|
@ -29,14 +29,14 @@ param
|
|||
|
||||
# MSBuild properties to execute build with. Default is @{'GenerateFullPaths'='true'}.
|
||||
[ValidateNotNull()]
|
||||
[Hashtable] $MSBuildProperties = @{'GenerateFullPaths'='true'},
|
||||
[Hashtable] $MSBuildProperties = @{'GenerateFullPaths' = 'true' },
|
||||
|
||||
# Build Configuration. Default is to use the MSBuild project defaults which is likely Debug.
|
||||
[ValidateSet($null, 'Debug', 'Release')]
|
||||
[string[]] $Configuration = @(),
|
||||
[string] $Configuration,
|
||||
|
||||
# Indicates to include the binary logger which can be used with the MSBuild Structured Log Viewer.
|
||||
[Alias('BL')]
|
||||
[Alias('BinLog', 'BL')]
|
||||
[switch] $BinaryLogger,
|
||||
|
||||
# Indicates to use Visual Studio Preview instead of released versions. Preview build must be installed in order to use.
|
||||
|
@ -58,63 +58,157 @@ param
|
|||
[switch] $AppVeyorLogger,
|
||||
|
||||
# Indicates to not build in parallel, removes the /m switch.
|
||||
[switch] $NoParallel
|
||||
[switch] $NoParallel,
|
||||
|
||||
# Indicates to force the use certain type of build.
|
||||
[ValidateSet('msbuild', 'dotnet')]
|
||||
[string] $BuildMode
|
||||
)
|
||||
|
||||
Import-Module $PSScriptRoot\FindVS.psm1
|
||||
$msbuildPath = Get-VSBuildFolder -Prerelease:$VSPreview
|
||||
|
||||
if(!$NoBuild) {
|
||||
$MSBuildTargets += 'Build'
|
||||
}
|
||||
|
||||
if($Pack) {
|
||||
$MSBuildTargets += 'Pack'
|
||||
}
|
||||
|
||||
if($Clean) {
|
||||
$MSBuildTargets += 'Clean'
|
||||
}
|
||||
|
||||
$MSBuildTargets = $MSBuildTargets | Select-Object -Unique
|
||||
|
||||
$resolvedSolutionFile = (Resolve-Path -Path $Solution -ErrorAction Stop).ProviderPath
|
||||
$msBuildArgs = @("`"$resolvedSolutionFile`"")
|
||||
if($MSBuildTargets.Count -gt 0) {
|
||||
$msBuildArgs += ('/t:' + ($MSBuildTargets -join ','))
|
||||
}
|
||||
|
||||
if($Configuration.Count -gt 0) {
|
||||
$MSBuildProperties['Configuration'] = $Configuration
|
||||
}
|
||||
|
||||
if($MSBuildProperties.Count -gt 0) {
|
||||
$properties = @()
|
||||
foreach($property in $MSBuildProperties.GetEnumerator()) {
|
||||
$properties += "$($property.Key)=$(($property.Value -join ','))"
|
||||
function InvokeMSBuild {
|
||||
try {
|
||||
Import-Module $PSScriptRoot\FindVS.psm1
|
||||
$msbuildPath = Get-VSBuildFolder -Prerelease:($VSPreview.IsPresent)
|
||||
}
|
||||
catch {
|
||||
if ($BuildMode -eq 'msbuild') {
|
||||
Write-Error "Failed to locate MSBuild. Ensure Visual Studio 2022 is installed and VS Dev Console loaded and try again." -ErrorAction Continue
|
||||
Write-Error $_ -ErrorAction Continue
|
||||
exit 1
|
||||
}
|
||||
else {
|
||||
Write-Warning "Failed to locate MSBuild. Falling back to dotnet build."
|
||||
InvokeDotNetBuild
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
$msBuildArgs += ('/p:' + ($properties -join ';'))
|
||||
if (!$NoBuild) {
|
||||
$MSBuildTargets += @('Build')
|
||||
}
|
||||
|
||||
if ($Pack) {
|
||||
$MSBuildTargets += @('Pack')
|
||||
}
|
||||
|
||||
if ($Clean) {
|
||||
$MSBuildTargets += @('Clean')
|
||||
}
|
||||
|
||||
$MSBuildTargets = $MSBuildTargets | Select-Object -Unique
|
||||
|
||||
$resolvedSolutionFile = (Resolve-Path -Path $Solution -ErrorAction Stop).ProviderPath
|
||||
$msBuildArgs = @("$resolvedSolutionFile")
|
||||
if ($MSBuildTargets.Count -gt 0) {
|
||||
$msBuildArgs += ('/t:' + ($MSBuildTargets -join ','))
|
||||
}
|
||||
|
||||
if ($Configuration) {
|
||||
$MSBuildProperties['Configuration'] = $Configuration
|
||||
}
|
||||
|
||||
if ($MSBuildProperties.Count -gt 0) {
|
||||
$properties = @()
|
||||
foreach ($property in $MSBuildProperties.GetEnumerator()) {
|
||||
$properties += "$($property.Key)=$(($property.Value -join ','))"
|
||||
}
|
||||
|
||||
$msBuildArgs += ('/p:' + ($properties -join ';'))
|
||||
}
|
||||
|
||||
if ($Restore -or $Clean) {
|
||||
$msBuildArgs += '/restore'
|
||||
}
|
||||
|
||||
if ($AppVeyorLogger) {
|
||||
# https://www.appveyor.com/docs/build-phase/
|
||||
$msBuildArgs += '/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"'
|
||||
}
|
||||
|
||||
if ($BinaryLogger) {
|
||||
$msBuildArgs += '/bl'
|
||||
}
|
||||
|
||||
if (!$NoParallel) {
|
||||
$msBuildArgs += '/m'
|
||||
}
|
||||
|
||||
Write-Host "Executing: & $msbuildPath $($msBuildArgs -join ' ')" -ForegroundColor Magenta
|
||||
$msBuildArgs | Out-Host
|
||||
|
||||
& $msbuildPath $msBuildArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
}
|
||||
|
||||
if ($Restore -or $Clean) {
|
||||
$msBuildArgs += '/restore'
|
||||
function InvokeDotNetBuild {
|
||||
if (!(Get-Command dotnet -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "dotnet not found. Ensure the .NET Core SDK is installed and available in the PATH." -ErrorAction Continue
|
||||
exit 1
|
||||
}
|
||||
|
||||
$fullSolutionPath = (Resolve-Path -Path $Solution -ErrorAction Stop).ProviderPath
|
||||
|
||||
# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build
|
||||
$dotnetArgs = @()
|
||||
if ($Pack -or $NoBuild) {
|
||||
$dotnetArgs += 'pack'
|
||||
}
|
||||
else {
|
||||
$dotnetArgs += 'build'
|
||||
}
|
||||
|
||||
if ($Configuration) {
|
||||
$dotnetArgs += '-c'
|
||||
$dotnetArgs += $Configuration
|
||||
}
|
||||
|
||||
if ($BinaryLogger) {
|
||||
$msBuildArgs += '-bl'
|
||||
}
|
||||
|
||||
if ($NoBuild) {
|
||||
$dotnetArgs += '--no-build'
|
||||
}
|
||||
|
||||
if (!$Restore) {
|
||||
$dotnetArgs += '--no-restore'
|
||||
}
|
||||
|
||||
if ($Clean) {
|
||||
#$dotnetArgs += '--no-incremental'
|
||||
Write-Host "Calling: dotnet clean $fullSolutionPath" -ForegroundColor Magenta
|
||||
& dotnet clean $fullSolutionPath
|
||||
}
|
||||
|
||||
if ($MSBuildProperties -and ($MSBuildProperties.Count -gt 0)) {
|
||||
foreach ($property in $MSBuildProperties.GetEnumerator()) {
|
||||
$dotnetArgs += "--property:$($property.Key)=$(($property.Value -join ','))"
|
||||
}
|
||||
}
|
||||
|
||||
$dotnetArgs += $fullSolutionPath
|
||||
|
||||
Write-Host "Calling: dotnet $($dotnetArgs -join ' ')" -ForegroundColor Magenta
|
||||
& dotnet $dotnetArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
}
|
||||
|
||||
if($AppVeyorLogger) {
|
||||
# https://www.appveyor.com/docs/build-phase/
|
||||
$msBuildArgs += '/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"'
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
Write-Verbose "Linux or MacOS detected, forcing DotNet build"
|
||||
$BuildMode = 'dotnet'
|
||||
}
|
||||
|
||||
if($BinaryLogger) {
|
||||
$msBuildArgs += '/bl'
|
||||
}
|
||||
|
||||
if(!$NoParallel) {
|
||||
$msBuildArgs += '/m'
|
||||
if ($BuildMode -eq 'dotnet') {
|
||||
InvokeDotNetBuild
|
||||
}
|
||||
else {
|
||||
Write-Verbose "Windows detected, checking for MSBuild"
|
||||
InvokeMSBuild
|
||||
}
|
||||
|
||||
Write-Verbose "Executing: & $msbuildPath $($msBuildArgs -join ' ')"
|
||||
& $msbuildPath $msBuildArgs
|
||||
|
||||
Write-Verbose "Build complete"
|
|
@ -42,7 +42,17 @@ Write-Host "DirectoryName: $DirectoryName"
|
|||
|
||||
# Build
|
||||
if(!$NoBuild) {
|
||||
& "$PSScriptRoot\Build.ps1"
|
||||
if ($IsWindows) {
|
||||
& "$PSScriptRoot\Build.ps1"
|
||||
}
|
||||
else {
|
||||
Write-Host "Calling: dotnet build --property:GenerateFullPaths=true" -ForegroundColor Magenta
|
||||
& dotnet build --property:GenerateFullPaths=true
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Failed to build" -ErrorAction Continue
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Locate test assembly
|
||||
|
@ -53,4 +63,15 @@ if(!$csProj) {
|
|||
|
||||
# Run tests
|
||||
Write-Host "Set breakpoint in test method '$TestName', and use .NET Core Attach to debug test (using process ID)" -ForegroundColor Magenta
|
||||
& "$PSScriptRoot\Test.ps1" -VSTestHostDebug -TestName $TestName -TestProject $csProj.BaseName -Filter '' # Set filter to empty string to allow interactive tests to be debugged
|
||||
|
||||
if ($IsWindows) {
|
||||
& "$PSScriptRoot\Test.ps1" -VSTestHostDebug -TestName $TestName -TestProject $csProj.BaseName -Filter '' # Set filter to empty string to allow interactive tests to be debugged
|
||||
}
|
||||
else {
|
||||
Write-Host "Calling: dotnet test --filter 'FullyQualifiedName~$TestName' --verbosity normal --logger trx --results-directory '$PSScriptRoot/../TestResults' $($csProj.FullName)" -ForegroundColor Magenta
|
||||
& dotnet test --no-build --no-restore --filter "FullyQualifiedName~$TestName" --verbosity normal --logger trx --results-directory "$PSScriptRoot/../TestResults" $csProj.FullName
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Failed to test" -ErrorAction Continue
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ param
|
|||
[switch] $EnableStrongName
|
||||
)
|
||||
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
throw "This script is meant to be run on Windows only"
|
||||
}
|
||||
|
||||
<#
|
||||
# Purpose: This script is meant for disabling strong name validation.
|
||||
# When building with Configuration=Release, the binaries are built with DelaySigned=true which causes strong name validation to take effect when loading.
|
||||
|
|
|
@ -6,6 +6,10 @@ function Get-VSBuildFolder
|
|||
[switch] $Prerelease
|
||||
)
|
||||
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
throw "This script is not supported on Linux or macOS. Use dotnet CLI instead."
|
||||
}
|
||||
|
||||
# https://github.com/Microsoft/vswhere
|
||||
$vsWhereExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if(!(Test-Path -Path $vsWhereExe)) {
|
||||
|
@ -19,6 +23,10 @@ function Get-VSBuildFolder
|
|||
|
||||
# https://github.com/microsoft/vswhere/wiki/Find-MSBuild#powershell
|
||||
$msbuildPath = & $vsWhereExe $vsWhereArgs | select-object -first 1
|
||||
if ((!$msbuildPath) -or ($LASTEXITCODE -ne 0)) {
|
||||
throw "Unable to find MSBuild using vswhere"
|
||||
}
|
||||
|
||||
if(!(Test-Path -Path $msbuildPath)) {
|
||||
throw "Unable to find MSBuild: $msbuildPath"
|
||||
}
|
||||
|
|
|
@ -19,26 +19,35 @@ param
|
|||
(
|
||||
# Path to SDK install directory
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $SdkInstallDir = 'C:\Program Files\dotnet\sdk\',
|
||||
[string] $SdkInstallDir = ($IsLinux) ? '/usr/share/dotnet/sdk' : 'C:\Program Files\dotnet\sdk\',
|
||||
|
||||
# The installed .NET SDK must have the same major and minor number and a lower build\patch number.
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $MajorMinorSDKVersionCheck = '3.1.427'
|
||||
[string] $MajorMinorSDKVersionCheck = '8.0.900'
|
||||
)
|
||||
|
||||
# .NET CORE 2.0 Downloads - https://www.microsoft.com/net/download/dotnet-core/2.0
|
||||
# .NET CORE 2.1 Downloads - https://www.microsoft.com/net/download/dotnet-core/2.1
|
||||
|
||||
$versionCheck = [version]$MajorMinorSDKVersionCheck
|
||||
$sdkVersions = Get-ChildItem $SdkInstallDir -Directory | Where-Object Name -Match '\d+\.\d+\.\d+$' | ForEach-Object {
|
||||
$version = [version]$_.BaseName
|
||||
$sdkVersions = Get-ChildItem -Path $SdkInstallDir -Directory | Where-Object Name -Match '\d+\.\d+\.\d+$' | ForEach-Object {
|
||||
$version = [version]($_.BaseName.Split('-') | Select-Object -First 1) # Remove any pre-release tags
|
||||
$_ | Add-Member -Name SDKVersion -MemberType NoteProperty -Value $version
|
||||
$_
|
||||
}
|
||||
$sdkDir = $sdkVersions | Where-Object { $_.SDKVersion.Major -eq $versionCheck.Major -and $_.SDKVersion.Minor -eq $versionCheck.Minor -and $_.SDKVersion.Build -lt $versionCheck.Build } | Sort-Object SDKVersion -Descending | Select-Object -First 1
|
||||
|
||||
if ($MajorMinorSDKVersionCheck) {
|
||||
Write-Verbose "Checking for SDK version less than: $MajorMinorSDKVersionCheck"
|
||||
$versionCheck = [version]$MajorMinorSDKVersionCheck
|
||||
$sdkDir = $sdkVersions | Where-Object { $_.SDKVersion.Major -eq $versionCheck.Major -and $_.SDKVersion.Minor -eq $versionCheck.Minor -and $_.SDKVersion.Build -lt $versionCheck.Build } | Sort-Object SDKVersion -Descending | Select-Object -First 1
|
||||
|
||||
if(!$sdkDir) {
|
||||
throw "Unable to find SDK version (less than $MajorMinorSDKVersionCheck) under: $SdkInstallDir`nVersions available: $(($sdkVersions | % { $_.BaseName }) -join ', ' )"
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Verbose "Checking for latest SDK version"
|
||||
$sdkDir = $sdkVersions | Sort-Object SDKVersion -Descending | Select-Object -First 1
|
||||
}
|
||||
|
||||
if(!$sdkDir) {
|
||||
throw "Unable to find SDK version (less than $MajorMinorSDKVersionCheck) under: $SdkInstallDir`nVersions available: $(($sdkVersions | % { $_.BaseName }) -join ', ' )"
|
||||
throw "Unable to find SDK version under: $SdkInstallDir"
|
||||
}
|
||||
|
||||
Write-Verbose "Using SDK: $($sdkDir.FullName)"
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
$tempDir = [IO.Path]::GetTempPath()
|
||||
if ($IsWindows) {
|
||||
$scriptPath = Join-Path -Path $tempDir -ChildPath 'dotnet-install.ps1'
|
||||
if (Test-Path -Path $scriptPath) {
|
||||
Remove-Item -Path $scriptPath -Force
|
||||
}
|
||||
|
||||
Write-Host 'Downloading https://dot.net/v1/dotnet-install.ps1'
|
||||
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -OutFile $scriptPath
|
||||
Unblock-File $scriptPath
|
||||
}
|
||||
elseif ($IsLinux -or $IsMacOS) {
|
||||
# Bash scripts work on both OS and are stored in the Linux directory
|
||||
# wget -q "https://dot.net/v1/dotnet-install.sh"
|
||||
$scriptPath = Join-Path -Path $tempDir -ChildPath 'dotnet-install.sh'
|
||||
if (Test-Path -Path $scriptPath) {
|
||||
Remove-Item -Path $scriptPath -Force
|
||||
}
|
||||
|
||||
Write-Host 'Downloading https://dot.net/v1/dotnet-install.sh'
|
||||
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.sh' -OutFile $scriptPath
|
||||
chmod +x $scriptPath
|
||||
}
|
||||
|
||||
$globalJsonPath = (Resolve-Path "$PSScriptRoot/../global.json" -ErrorAction Stop).ProviderPath
|
||||
|
||||
# For arguments to dotnet script see:
|
||||
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
|
||||
|
||||
if ($IsWindows) {
|
||||
Write-Host "Executing: $scriptPath -JSonFile $globalJsonPath"
|
||||
& $scriptPath -JSonFile $globalJsonPath
|
||||
}
|
||||
elseif ($IsLinux -or $IsMacOS) {
|
||||
Write-Host "Executing: $scriptPath --jsonfile `"$globalJsonPath`""
|
||||
& $scriptPath --jsonfile "$globalJsonPath"
|
||||
}
|
||||
else {
|
||||
Write-Error "Unsupported OS platform" -ErrorAction Continue
|
||||
exit 1
|
||||
}
|
|
@ -9,6 +9,10 @@ param
|
|||
[switch] $VSPreview
|
||||
)
|
||||
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
throw "This script is not supported on Linux or macOS. Use dotnet CLI instead."
|
||||
}
|
||||
|
||||
Import-Module $PSScriptRoot\FindVS.psm1
|
||||
$msbuildPath = Get-VSBuildFolder -Prerelease:$VSPreview
|
||||
|
||||
|
|
|
@ -75,8 +75,10 @@ if(!$LoadOnly) {
|
|||
|
||||
if($env:PSModulePath -split ';' -inotcontains $PackageDir) {
|
||||
Write-Verbose "Adding '$PackageDir' to PSModulePath environment variable..."
|
||||
$env:PSModulePath = $env:PSModulePath.TrimEnd(';')
|
||||
$env:PSModulePath += ";$PackageDir"
|
||||
$pathSeperator = [System.IO.Path]::PathSeparator
|
||||
|
||||
$env:PSModulePath = $env:PSModulePath.TrimEnd($pathSeperator)
|
||||
$env:PSModulePath += "$($pathSeperator)$PackageDir"
|
||||
}
|
||||
|
||||
Write-Output "[Done] Updated PSModulePath with '$PackageDir', you can now invoke cmdlets (causes module auto-loading)"
|
|
@ -82,8 +82,13 @@ $ReleaseNotes
|
|||
|
||||
if($updatePsdFile) {
|
||||
Write-Output "Updating module file: $ModulePath"
|
||||
$utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($false)
|
||||
[System.IO.File]::WriteAllText($ModulePath, $psdFileContent, $utf8NoBomEncoding)
|
||||
if ($IsWindows) {
|
||||
$utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($false)
|
||||
[System.IO.File]::WriteAllText($ModulePath, $psdFileContent, $utf8NoBomEncoding)
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $ModulePath -Value $psdFileContent -Encoding UTF8 -Force
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Warning "No updates made to module file: $ModulePath"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Common.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Common.Test</RootNamespace>
|
||||
|
|
|
@ -64,9 +64,9 @@ namespace Microsoft.PowerBI.Commands.Common
|
|||
|
||||
// Handle MSAL assemblies
|
||||
string assemblyFilePath;
|
||||
if (requestedAssembly.Name == "Microsoft.Identity.Client" || requestedAssembly.Name == "Microsoft.Identity.Client.Extensions.Msal")
|
||||
if (requestedAssembly.Name == "Microsoft.Identity.Client" || requestedAssembly.Name == "Microsoft.Identity.Client.Extensions.Msal" || requestedAssembly.Name == "Microsoft.Identity.Client.Broker")
|
||||
{
|
||||
var libType = IsNetFramework ? "net45" : "netcoreapp2.1";
|
||||
var libType = "netstandard2.0";
|
||||
assemblyFilePath = Path.Combine(executingDirectory, "MSAL", libType, requestedAssembly.Name + ".dll");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
|
||||
<PackageReference Include="Microsoft.Identity.Client" />
|
||||
<PackageReference Include="Microsoft.Identity.Client.Broker" />
|
||||
<PackageReference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -6,15 +6,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Identity.Client;
|
||||
using Microsoft.Identity.Client.Broker;
|
||||
using Microsoft.PowerBI.Common.Abstractions.Interfaces;
|
||||
|
||||
namespace Microsoft.PowerBI.Common.Authentication
|
||||
{
|
||||
public class DeviceCodeAuthenticationFactory : IAuthenticationUserFactory
|
||||
{
|
||||
private enum GetAncestorFlags
|
||||
{
|
||||
GetParent = 1,
|
||||
GetRoot = 2,
|
||||
/// <summary>
|
||||
/// Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent.
|
||||
/// </summary>
|
||||
GetRootOwner = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the handle to the ancestor of the specified window.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">A handle to the window whose ancestor is to be retrieved.
|
||||
/// If this parameter is the desktop window, the function returns NULL. </param>
|
||||
/// <param name="flags">The ancestor to be retrieved.</param>
|
||||
/// <returns>The return value is the handle to the ancestor window.</returns>
|
||||
[DllImport("user32.dll", ExactSpelling = true)]
|
||||
static extern IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags flags);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern IntPtr GetConsoleWindow();
|
||||
|
||||
// window handle
|
||||
private IntPtr GetConsoleOrTerminalWindow()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
IntPtr consoleHandle = GetConsoleWindow();
|
||||
IntPtr handle = GetAncestor(consoleHandle, GetAncestorFlags.GetRootOwner);
|
||||
|
||||
return handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException("This method is only supported on Windows.");
|
||||
}
|
||||
}
|
||||
|
||||
private IPublicClientApplication AuthApplication;
|
||||
|
||||
public async Task<IAccessToken> Authenticate(IPowerBIEnvironment environment, IPowerBILogger logger, IPowerBISettings settings, IDictionary<string, string> queryParameters = null)
|
||||
|
@ -22,12 +63,26 @@ namespace Microsoft.PowerBI.Common.Authentication
|
|||
IEnumerable<string> scopes = new[] { $"{environment.AzureADResource}/.default" };
|
||||
if (this.AuthApplication == null)
|
||||
{
|
||||
this.AuthApplication = PublicClientApplicationBuilder
|
||||
.Create(environment.AzureADClientId)
|
||||
.WithAuthority(environment.AzureADAuthority)
|
||||
.WithLogging((level, message, containsPii) => LoggingUtils.LogMsal(level, message, containsPii, logger))
|
||||
.WithRedirectUri(environment.AzureADRedirectAddress)
|
||||
.Build();
|
||||
// WAM is only supported on Windows
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
this.AuthApplication = PublicClientApplicationBuilder
|
||||
.Create(environment.AzureADClientId)
|
||||
.WithAuthority(environment.AzureADAuthority)
|
||||
.WithLogging((level, message, containsPii) => LoggingUtils.LogMsal(level, message, containsPii, logger))
|
||||
.WithBroker(new BrokerOptions(BrokerOptions.OperatingSystems.Windows))
|
||||
.WithParentActivityOrWindow(GetConsoleOrTerminalWindow)
|
||||
.Build();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AuthApplication = PublicClientApplicationBuilder
|
||||
.Create(environment.AzureADClientId)
|
||||
.WithAuthority(environment.AzureADAuthority)
|
||||
.WithLogging((level, message, containsPii) => LoggingUtils.LogMsal(level, message, containsPii, logger))
|
||||
.WithRedirectUri(environment.AzureADRedirectAddress)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
||||
AuthenticationResult result = null;
|
||||
|
|
|
@ -15,6 +15,7 @@ using System.Security.Authentication;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Identity.Client;
|
||||
using Microsoft.Identity.Client.Broker;
|
||||
using Microsoft.PowerBI.Common.Abstractions.Interfaces;
|
||||
using Microsoft.PowerBI.Common.Abstractions.Utilities;
|
||||
|
||||
|
@ -22,6 +23,45 @@ namespace Microsoft.PowerBI.Common.Authentication
|
|||
{
|
||||
public class WindowsAuthenticationFactory : IAuthenticationUserFactory
|
||||
{
|
||||
private enum GetAncestorFlags
|
||||
{
|
||||
GetParent = 1,
|
||||
GetRoot = 2,
|
||||
/// <summary>
|
||||
/// Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent.
|
||||
/// </summary>
|
||||
GetRootOwner = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the handle to the ancestor of the specified window.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">A handle to the window whose ancestor is to be retrieved.
|
||||
/// If this parameter is the desktop window, the function returns NULL. </param>
|
||||
/// <param name="flags">The ancestor to be retrieved.</param>
|
||||
/// <returns>The return value is the handle to the ancestor window.</returns>
|
||||
[DllImport("user32.dll", ExactSpelling = true)]
|
||||
static extern IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags flags);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern IntPtr GetConsoleWindow();
|
||||
|
||||
// window handle
|
||||
private IntPtr GetConsoleOrTerminalWindow()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
IntPtr consoleHandle = GetConsoleWindow();
|
||||
IntPtr handle = GetAncestor(consoleHandle, GetAncestorFlags.GetRootOwner);
|
||||
|
||||
return handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException("This method is only supported on Windows.");
|
||||
}
|
||||
}
|
||||
|
||||
private IPublicClientApplication AuthApplication;
|
||||
|
||||
public async Task<IAccessToken> Authenticate(IPowerBIEnvironment environment, IPowerBILogger logger, IPowerBISettings settings, IDictionary<string, string> queryParameters = null)
|
||||
|
@ -73,6 +113,10 @@ namespace Microsoft.PowerBI.Common.Authentication
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (MsalUiRequiredException)
|
||||
{
|
||||
result = await this.AuthApplication.AcquireTokenInteractive(scopes).ExecuteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new AuthenticationException($"Error Acquiring Token:{System.Environment.NewLine}{ex.Message}");
|
||||
|
@ -109,12 +153,27 @@ namespace Microsoft.PowerBI.Common.Authentication
|
|||
// auth application is auto cleared when there's no account
|
||||
if (this.AuthApplication == null)
|
||||
{
|
||||
var authApplicationBuilder = PublicClientApplicationBuilder
|
||||
PublicClientApplicationBuilder authApplicationBuilder = null;
|
||||
// WAM is only supported on Windows
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
authApplicationBuilder = PublicClientApplicationBuilder
|
||||
.Create(environment.AzureADClientId)
|
||||
.WithAuthority(environment.AzureADAuthority)
|
||||
.WithLogging((level, message, containsPii) => LoggingUtils.LogMsal(level, message, containsPii, logger))
|
||||
.WithExtraQueryParameters(queryParameters)
|
||||
.WithBroker(new BrokerOptions(BrokerOptions.OperatingSystems.Windows))
|
||||
.WithParentActivityOrWindow(GetConsoleOrTerminalWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
authApplicationBuilder = PublicClientApplicationBuilder
|
||||
.Create(environment.AzureADClientId)
|
||||
.WithAuthority(environment.AzureADAuthority)
|
||||
.WithLogging((level, message, containsPii) => LoggingUtils.LogMsal(level, message, containsPii, logger))
|
||||
.WithExtraQueryParameters(queryParameters)
|
||||
.WithRedirectUri(environment.AzureADRedirectAddress);
|
||||
}
|
||||
|
||||
if (!PublicClientHelper.IsNetFramework)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Admin.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Admin.Test</RootNamespace>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Capacities.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Capacities.Test</RootNamespace>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Data.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Data.Test</RootNamespace>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Profile.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Profile.Test</RootNamespace>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Reports.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Reports.Test</RootNamespace>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.PowerBI.Commands.Workspaces.Test</AssemblyName>
|
||||
<RootNamespace>Microsoft.PowerBI.Commands.Workspaces.Test</RootNamespace>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "1.3",
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/master$",
|
||||
"^refs/heads/v\\d+(?:\\.\\d+)?$"
|
||||
],
|
||||
"cloudBuild": {
|
||||
"buildNumber": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче