From d92620dcf36b76d27791bfaeed656f6914c0856c Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 03:42:54 -0700 Subject: [PATCH 1/3] Move resgen artifacts from submodules into src subfolders Submodule adds unnessesary complexity. This commit removes dependency on pre-generated C# bindings. Start-PsBuild -ResGen will call Start-ResGen. It also has auto-detect logic to simplify first time expirience. --- .gitignore | 3 +++ build.psm1 | 17 ++++++++++++++--- .../project.json | 6 ------ .../project.json | 6 ------ .../project.json | 1 - .../project.json | 3 +-- .../project.json | 3 +-- src/Microsoft.PowerShell.Security/project.json | 6 ------ src/System.Management.Automation/project.json | 7 ------- 9 files changed, 19 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 214134621..ea82ac5cd 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ powershell.version # default location for produced nuget packages /nuget-artifacts + +# resgen output +gen diff --git a/build.psm1 b/build.psm1 index a82565c9a..ded6e6e00 100644 --- a/build.psm1 +++ b/build.psm1 @@ -26,6 +26,7 @@ function Start-PSBuild { [switch]$NoPath, [switch]$Restore, [string]$Output, + [switch]$ResGen, [Parameter(ParameterSetName='CoreCLR')] [switch]$Publish, @@ -143,6 +144,13 @@ function Start-PSBuild { Start-NativeExecution { dotnet restore $RestoreArguments } } + # handle ResGen + if ($ResGen -or -not (Test-Path "$($Options.Top)/gen")) + { + log "Run ResGen (generating C# bindings for resx files)" + Start-ResGen + } + # Build native components if ($IsLinux -or $IsOSX) { $Ext = if ($IsLinux) { @@ -867,6 +875,9 @@ function Send-GitDiffToSd { function Start-ResGen { + [CmdletBinding()] + param() + @("Microsoft.PowerShell.Commands.Management", "Microsoft.PowerShell.Commands.Utility", "Microsoft.PowerShell.ConsoleHost", @@ -890,9 +901,9 @@ function Start-ResGen } $genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className -NamespaceName $namespace - $outPath = "$PSScriptRoot/src/windows-build/gen/$module/$fileName.cs" - log "ResGen for $outPath" - mkdir -ErrorAction SilentlyContinue (Split-Path $outPath) > $null + $outPath = "$PSScriptRoot/src/$module/gen/$fileName.cs" + Write-Verbose "ResGen for $outPath" + New-Item -Type Directory -ErrorAction SilentlyContinue (Split-Path $outPath) > $null Set-Content -Encoding Ascii -Path $outPath -Value $genSource } } diff --git a/src/Microsoft.PowerShell.Commands.Management/project.json b/src/Microsoft.PowerShell.Commands.Management/project.json index 8ceb0ff97..32935f639 100644 --- a/src/Microsoft.PowerShell.Commands.Management/project.json +++ b/src/Microsoft.PowerShell.Commands.Management/project.json @@ -18,7 +18,6 @@ "buildOptions": { "define": [ "CORECLR" ], "compile": { - "include": [ "../windows-build/gen/Microsoft.PowerShell.Commands.Management/*.cs" ], "exclude": [ "commands/management/ClearRecycleBinCommand.cs", "commands/management/CommitTransactionCommand.cs", @@ -48,11 +47,6 @@ } }, "net451": { - "buildOptions": { - "compile": { - "include": [ "../windows-build/gen/Microsoft.PowerShell.Commands.Management/*.cs" ] - } - }, "frameworkAssemblies": { "System.ServiceProcess": "", "System.Windows.Forms": "", diff --git a/src/Microsoft.PowerShell.Commands.Utility/project.json b/src/Microsoft.PowerShell.Commands.Utility/project.json index 2fb1899e6..6f0187bca 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/project.json +++ b/src/Microsoft.PowerShell.Commands.Utility/project.json @@ -17,7 +17,6 @@ "buildOptions": { "define": [ "CORECLR" ], "compile": { - "include": [ "../windows-build/gen/Microsoft.PowerShell.Commands.Utility/*.cs" ], "exclude": [ "commands/utility/FormatAndOutput/OutGridView/ColumnInfo.cs", "commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs", @@ -65,11 +64,6 @@ } }, "net451": { - "buildOptions": { - "compile": { - "include": [ "../windows-build/gen/Microsoft.PowerShell.Commands.Utility/*.cs" ] - } - }, "frameworkAssemblies": { "System.Drawing": "", "System.Web": "", diff --git a/src/Microsoft.PowerShell.ConsoleHost/project.json b/src/Microsoft.PowerShell.ConsoleHost/project.json index b0c78a535..e5644d200 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/project.json +++ b/src/Microsoft.PowerShell.ConsoleHost/project.json @@ -7,7 +7,6 @@ "buildOptions": { "warningsAsErrors": true, "allowUnsafe": true, - "compile": [ "../windows-build/gen/Microsoft.PowerShell.ConsoleHost/*.cs" ], "copyToOutput": { "include": [ "Modules", diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json b/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json index 2ff44c9ba..9b43cd257 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/project.json @@ -5,8 +5,7 @@ "buildOptions": { "warningsAsErrors": true, - "allowUnsafe": true, - "compile": [ "../windows-build/gen/Microsoft.PowerShell.CoreCLR.Eventing/*.cs" ] + "allowUnsafe": true }, "frameworks": { diff --git a/src/Microsoft.PowerShell.LocalAccounts/project.json b/src/Microsoft.PowerShell.LocalAccounts/project.json index 7a1f812da..bc9472d32 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/project.json +++ b/src/Microsoft.PowerShell.LocalAccounts/project.json @@ -4,8 +4,7 @@ "authors": [ "OPS" ], "buildOptions": { - "warningsAsErrors": true, - "compile": [ "../windows-build/gen/Microsoft.PowerShell.LocalAccounts/*.cs" ] + "warningsAsErrors": true }, "dependencies": { diff --git a/src/Microsoft.PowerShell.Security/project.json b/src/Microsoft.PowerShell.Security/project.json index 28d548fed..2e8c11b49 100644 --- a/src/Microsoft.PowerShell.Security/project.json +++ b/src/Microsoft.PowerShell.Security/project.json @@ -18,7 +18,6 @@ "buildOptions": { "define": [ "CORECLR" ], "compile": { - "include": [ "../windows-build/gen/Microsoft.PowerShell.Security/*.cs" ], "exclude": [ "security/CertificateCommands.cs", "security/CmsCommands.cs", @@ -28,11 +27,6 @@ } }, "net451": { - "buildOptions": { - "compile": { - "include": [ "../windows-build/gen/Microsoft.PowerShell.Security/*.cs" ] - } - } } } } diff --git a/src/System.Management.Automation/project.json b/src/System.Management.Automation/project.json index d76b0e9b5..deb701208 100644 --- a/src/System.Management.Automation/project.json +++ b/src/System.Management.Automation/project.json @@ -26,7 +26,6 @@ "buildOptions": { "define": [ "CORECLR" ], "compile": { - "include": [ "../windows-build/gen/System.Management.Automation/*.cs" ], "exclude": [ "cimSupport/cmdletization/xml/cmdlets-over-objects.objectModel.autogen.cs", "cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs", @@ -163,12 +162,6 @@ } }, "net451": { - "buildOptions": { - "compile": { - "include": [ "../windows-build/gen/System.Management.Automation/*.cs" ] - - } - }, "frameworkAssemblies": { "System.Runtime": "", "System.Xml": "", From 94e3be208a0712065a9a9fd86f4a1323ef7920f8 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 03:49:46 -0700 Subject: [PATCH 2/3] Update resources.md doc, partialy fix #746 --- docs/workflow/resources.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/docs/workflow/resources.md b/docs/workflow/resources.md index 874394de8..7cd7071f8 100644 --- a/docs/workflow/resources.md +++ b/docs/workflow/resources.md @@ -5,9 +5,13 @@ They live in `src\\resources` folders. At the moment `dotnet cli` doesn't support generating C# bindings (strongly typed resource files). -We are using `src\windows-build\gen` folder in [src\windows-build](https://github.com/PowerShell/psl-windows-build) -with pre-generated `.cs` files to work-around it. -See [issue 756](https://github.com/PowerShell/PowerShell/issues/746) for details. +We are using our own `Start-ResGen` to generate them. + +Usually it's called as part of the regular build with + +``` +Start-PSBuild -ResGen +``` ## Editing resx files @@ -17,15 +21,6 @@ It will try to create `.cs` files for you and you will get whole bunch of hard-t To edit resource file, use any **plain text editor**. Resource file is a simple xml, and it's easy to edit. -### Updating string +## Adding resx files -If you just updated the string value, that's all you need to do: no need to re-generate `.cs` files - -### Adding or removing string - -When you adding or removing string, `.cs` file need to be changed. - -1. Run `Start-ResGen` function from `build.psm1` -1. Make sure your code is building with newly generated resources (run `Start-PSBuild`). -1. Go to submodule (`cd src\windows-build`) and perform the [submodule commit dance](../git/committing.md). -Follow working with [submodule rules](../../.github/CONTRIBUTING.md#submodules) +Add corresponding entries in `Start-ResGen` in `.\build.psm1`. From 65acf49845af1ce11513999e9752943c812a4c28 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 08:29:42 -0700 Subject: [PATCH 3/3] Replace aliases by full names to fix build --- build.psm1 | 4 ++-- src/windows-build | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.psm1 b/build.psm1 index ded6e6e00..ed1709f39 100644 --- a/build.psm1 +++ b/build.psm1 @@ -886,9 +886,9 @@ function Start-ResGen "Microsoft.PowerShell.Security", "System.Management.Automation") | % { $module = $_ - ls "$PSScriptRoot/src/$module/resources" | % { + Get-ChildItem "$PSScriptRoot/src/$module/resources" | % { $className = $_.Name.Replace('.resx', '') - $xml = [xml](cat -raw $_.FullName) + $xml = [xml](Get-Content -raw $_.FullName) $fileName = $className $namespace = '' diff --git a/src/windows-build b/src/windows-build index 9598137e1..4011f04c0 160000 --- a/src/windows-build +++ b/src/windows-build @@ -1 +1 @@ -Subproject commit 9598137e1ec976c23328880534a8f49bdce32cf0 +Subproject commit 4011f04c040c88441dd93ec53191e5540832ee21