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
51 changes: 51 additions & 0 deletions tools/AzDev/AzDev/AzDev.format.ps1xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>PSProject</Name>
<ViewSelectedBy>
<TypeName>AzDev.Models.PSModels.PSProject</TypeName>
</ViewSelectedBy>
<TableControl>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Type</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Path</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PSModule</Name>
<ViewSelectedBy>
<TypeName>AzDev.Models.PSModels.PSModule</TypeName>
</ViewSelectedBy>
<TableControl>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Type</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Path</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
135 changes: 135 additions & 0 deletions tools/AzDev/AzDev/AzDev.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#
# Module manifest for module 'AzDev'
#
# Generated by: Yeming Liu
#
# Generated on: 7/5/2024
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'AzDev.psm1'

# Version number of this module.
ModuleVersion = '0.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'e989d571-a6ed-4912-bf5c-7b0c55261607'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = 'Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @('AzDev.format.ps1xml')

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('bin/AzDev.dll',
'CommonRepo.psm1')

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Connect-DevCommonRepo', 'Disconnect-DevCommonRepo'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'Get-DevContext', 'Set-DevContext',
'Get-DevModule', 'Get-DevProject',
'Open-DevSwagger'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

Empty file added tools/AzDev/AzDev/AzDev.psm1
Empty file.
115 changes: 115 additions & 0 deletions tools/AzDev/AzDev/CommonRepo.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Connects azure-powershell repo to azure-powershell-common repo for debugging.

.Description
Connects azure-powershell repo to azure-powershell-common repo for debugging.

.Parameter CommonRepoPath
Path to the common repo. Relative or absolute.

.Example
Connect-CommonRepo -CommonRepoPath ../azure-powershell-common
#>
function Connect-DevCommonRepo {
[CmdletBinding()]
param()

$context = Get-DevContext

Write-Host "1/2 Adding common projects to sln and csproj"

$CommonRepoPath = $context.AzurePowerShellCommonRepositoryRoot
$CommonProjects = Get-ChildItem -Path "$CommonRepoPath/src/" -Include *.csproj -Exclude *.test.* -Recurse
$CommonProjects = $CommonProjects.FullName


$RepoRoot = $Context.AzurePowerShellRepositoryRoot

Push-Location "$RepoRoot/src/Accounts"
try {
foreach ($csproj in $CommonProjects) {
$csproj = [System.IO.Path]::GetFullPath($csproj)
dotnet sln add $csproj
if ($LASTEXITCODE -ne 0) {
throw "Failed to add $csproj to Accounts.sln"
}
<#
known common project references:
Authentication.csproj -> Authentication.Abstractions, ResourceManager
Accounts.csproj -> Authentication.Abstractions, ResourceManager, Common
Accounts.Test.csproj -> Authentication.Abstractions, ResourceManager, Common
TestFx.csproj -> Graph.Rbac.csproj
AssemblyLoading.csproj -> Common
#>
# add all common projects to Authentication.csproj because it will be referenced by most Az projects
dotnet add ./Authentication/Authentication.csproj reference $csproj
if ($LASTEXITCODE -ne 0) {
throw "Failed to add $csproj to Authentication.csproj"
}
}

# AssemblyLoading.csproj references Common.csproj and does not reference Authentication.csproj
dotnet add ./AssemblyLoading/AssemblyLoading.csproj reference "$CommonRepoPath/src/Common/Common.csproj"
if ($LASTEXITCODE -ne 0) {
throw "Failed to add Common.csproj to AssemblyLoading.csproj"
}

# add common project references below for csproj which does not reference Authentication.csproj
}
finally {
Pop-Location
}


Write-Host "2/2: Remove the dependency of those common projects from .targets file"

$Patterns = @(
'<PackageReference Include="Microsoft.Azure.PowerShell'
)
$TargetsFile = (Resolve-Path "$RepoRoot/tools/Common.Netcore.Dependencies.targets").Path
(Get-Content $TargetsFile) | ForEach-Object { # https://stackoverflow.com/questions/10480673/find-and-replace-in-files-fails
[string]$line = $_
$IsMatch = $false
foreach ($pattern in $patterns) {
if ($line.IndexOf($pattern) -ne -1) {
$IsMatch = $true
break
}
}
if ($IsMatch -and -not $line.StartsWith('<!--')) {
return "<!--$line-->"
}
else {
return $line
}
} | Set-Content $TargetsFile

Write-Host "Done connecting both repositories."
}

function Disconnect-DevCommonRepo {
Write-Host "Please run the following commands to undo Connect-CommonRepo. Double check those files do not have wanted changes.
git checkout -- ./src/Accounts/Accounts.sln
git checkout -- ./src/Accounts/AssemblyLoading/AssemblyLoading.csproj
git checkout -- ./src/Accounts/Authentication/Authentication.csproj
git checkout -- ./tools/Common.Netcore.Dependencies.targets
"
}

Export-ModuleMember -Function Connect-DevCommonRepo, Disconnect-DevCommonRepo
40 changes: 40 additions & 0 deletions tools/AzDev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Next
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this changelog finalized? any plan to group changes with version number?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer it to the day when we publish the module somewhere, then versioning will be essential.

- Feature: further distinguish track 1/2 SDKs, data/management plane, package/project.
- Local static analysis (Invoke-AzStaticAnalyzer)
- New-TestEnvironment and other existing tools
- Scripts to help deploy compliant resources
- Look into tools/, what else can be ported here?
- Install daily build
- Check what CLI's az dev support?
- Wildcard of project and module names - need to implement by hand? Can leverage `DirectoryInfo.GetFiles`? It supports kind of wildcard.
- Quick start templates
- Versioning and publishing AzDev module

## 2025/1/2
- Misc: moved to azure-powershell repo
- Feature: Connect common repo and ps repo

## 2024/12/30
- Fix: path issue on Windows
- Misc: Better error message when no context

## 2024/12/27
- Feature: Distinguish SDK-based projects, wrapper projects and other projects.
- Feature: Distinguish modules types: SdkBased, autorestBased, Hybrid.

## 2024/12/25
- Fix: Inventory cmdlets ignore live tests

## 2024/10/15
- Feature: Add reason for deducing project type

## 2024/9/11
- Feature: Open swagger link
- Rename SDK-based project type to "Other" because there's no accurate way to distinguish between SDK and wrapper projects

## Older
- Fix: Two misidentified projects because of live tests: ContainerRegistry and Resources
- Feature: Get-DevProject: Add support for `-Type` parameter
- Feature: Add new ProjectType: Test, LegacyHelper, Track1Sdk
- Renamed "Submodule" to "Project"
- Feature: Added "Get-DevProject" cmdlet
Loading