-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate assemblyinfo.cs for new module #1376
Changes from 7 commits
695f27a
f0f2e31
89e4122
df94564
6e1f41c
e4a710c
50b57bf
48fa49a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,11 +166,17 @@ if (Test-Path (Join-Path $PSScriptRoot 'generate-portal-ux.ps1')) | |
. (Join-Path $PSScriptRoot 'generate-portal-ux.ps1') | ||
} | ||
|
||
$assemblyInfoPath = Join-Path $PSScriptRoot 'Properties' 'AssemblyInfo.cs' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we only have it for Azure. |
||
if (-not (Test-Path $assemblyInfoPath)) { | ||
Write-Host -ForegroundColor Green 'Creating assembly info...' | ||
New-AssemblyInfo | ||
} | ||
|
||
if (-not $DisableAfterBuildTasks){ | ||
$afterBuildTasksPath = Join-Path $PSScriptRoot '${$project.afterBuildTasksPath}' | ||
$afterBuildTasksArgs = ConvertFrom-Json '${$project.afterBuildTasksArgs}' -AsHashtable | ||
if(Test-Path -Path $afterBuildTasksPath -PathType leaf){ | ||
Write-Host -ForegroundColor Green 'Running after build tasks...' | ||
Write-Host -ForegroundColor Green 'Executing after build tasks...' | ||
. $afterBuildTasksPath @afterBuildTasksArgs | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using System.Text; | ||
|
||
namespace Microsoft.Rest.ClientRuntime.PowerShell | ||
{ | ||
[Cmdlet("New", "AssemblyInfo")] | ||
[DoNotExport] | ||
public class NewAssemblyInfo : PSCmdlet | ||
{ | ||
private readonly string assemblyInfoPath = Path.Combine("${$project.baseFolder}", "Properties", "AssemblyInfo.cs"); | ||
private const string assemblyName = "${$project.title}"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use $(module-name) instead of title here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. module-name is Az.xxx, title is without Az, I want it to be without 'Az' |
||
private const string assemblyVersion = "${$project.moduleVersion}"; | ||
private const string assemblyCompanyName = "${$project.assemblyCompany}"; | ||
private const string assemblyProduct = "${$project.assemblyProduct}"; | ||
private const string assemblyCopyright = "${$project.assemblyCopyright}"; | ||
protected override void ProcessRecord() | ||
{ | ||
try | ||
{ | ||
if (File.Exists(assemblyInfoPath)) | ||
{ | ||
return; | ||
} | ||
StringBuilder sb = new StringBuilder(); | ||
sb.AppendLine(@" | ||
# ---------------------------------------------------------------------------------- | ||
${$project.pwshCommentHeaderForCsharp} | ||
# ---------------------------------------------------------------------------------- | ||
"); | ||
sb.Append($"{Environment.NewLine}"); | ||
sb.AppendLine("using System;"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could consider hardcode all the stuff except for assemblyName, Guid, and assemblyVersion. |
||
sb.AppendLine("using System.Reflection;"); | ||
sb.AppendLine("using System.Runtime.InteropServices;"); | ||
sb.Append($"{Environment.NewLine}"); | ||
sb.AppendLine($"[assembly: AssemblyTitle(\"Microsoft Azure Powershell - {assemblyName}\")]"); | ||
sb.AppendLine($"[assembly: AssemblyCompany(\"{assemblyCompanyName}\")]"); | ||
sb.AppendLine($"[assembly: AssemblyProduct(\"{assemblyProduct}\")]"); | ||
sb.AppendLine($"[assembly: AssemblyCopyright(\"{assemblyCopyright}\")]"); | ||
sb.Append($"{Environment.NewLine}"); | ||
sb.AppendLine("[assembly: ComVisible(false)]"); | ||
sb.AppendLine("[assembly: CLSCompliant(false)]"); | ||
sb.AppendLine($"[assembly: Guid(\"{Guid.NewGuid()}\")]"); | ||
sb.AppendLine($"[assembly: AssemblyVersion(\"{assemblyVersion}\")]"); | ||
sb.Append($"[assembly: AssemblyFileVersion(\"{assemblyVersion}\")]"); | ||
|
||
FileInfo assemblyInfo = new FileInfo(assemblyInfoPath); | ||
assemblyInfo.Directory.Create(); | ||
File.WriteAllText(assemblyInfo.FullName, sb.ToString()); | ||
} | ||
catch (Exception ee) | ||
{ | ||
Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); | ||
throw ee; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just hardcode the assemblyInfoFolder to Properties