diff --git a/powershell/generators/AssemblyInfo.ts b/powershell/generators/AssemblyInfo.ts new file mode 100644 index 0000000000..5430716273 --- /dev/null +++ b/powershell/generators/AssemblyInfo.ts @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Project } from '../internal/project'; + +export async function generateAssemblyInfo(project: Project) { + if (!project.azure || !project.assemblyInfoPath) { + return; + } + + const info = `${project.csharpCommentHeaderForCsharp} + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: System.Reflection.AssemblyCompanyAttribute("${project.assemblyCompany}")] +[assembly: System.Reflection.AssemblyCopyrightAttribute("${project.assemblyCopyright}")] +[assembly: System.Reflection.AssemblyProductAttribute("${project.assemblyProduct}")] +[assembly: System.Reflection.AssemblyTitleAttribute("${project.assemblyProduct} - ${project.title}")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.0.0")] +[assembly: System.Reflection.AssemblyVersionAttribute("0.1.0.0")] +[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] +[assembly: System.CLSCompliantAttribute(false)]`; + + project.state.writeFile(project.assemblyInfoPath, info, undefined, 'source-file-csharp'); +} \ No newline at end of file diff --git a/powershell/generators/csproj.ts b/powershell/generators/csproj.ts index e06535a328..5f48aa9958 100644 --- a/powershell/generators/csproj.ts +++ b/powershell/generators/csproj.ts @@ -15,22 +15,6 @@ export async function generateCsproj(project: Project) { TRACE;RELEASE;NETSTANDARD;SIGN` : ' TRACE;RELEASE;NETSTANDARD'; - const assemblyinfo = project.azure ? ` - ${project.assemblyInfoPath} - ${project.assemblyCompany} - ${project.assemblyProduct} - ${project.assemblyCopyright} - ${project.assemblyProduct} - ${project.title} - - - - <_Parameter1>false - - - <_Parameter1>false - - ` : ''; - project.state.writeFile(project.csproj, ` @@ -39,6 +23,7 @@ export async function generateCsproj(project: Project) { netstandard2.0 Library ${project.dllName} + false ${project.projectNamespace} true false @@ -52,7 +37,6 @@ export async function generateCsproj(project: Project) { true - ${assemblyinfo} false TRACE;DEBUG;NETSTANDARD diff --git a/powershell/plugins/powershell-v2.ts b/powershell/plugins/powershell-v2.ts index d97f1ace96..3d00e8f501 100644 --- a/powershell/plugins/powershell-v2.ts +++ b/powershell/plugins/powershell-v2.ts @@ -17,6 +17,7 @@ import { generateGitIgnore } from '../generators/gitignore'; import { generateGitAttributes } from '../generators/gitattributes'; import { generateReadme } from '../generators/readme'; import { generateScriptCmdlets } from '../generators/script-cmdlet'; +import { generateAssemblyInfo } from '../generators/AssemblyInfo'; const sourceFileCSharp = 'source-file-csharp'; const resources = `${__dirname}/../../resources`; @@ -73,6 +74,7 @@ export async function powershellV2(service: Host) { await generateGitIgnore(project); await generateGitAttributes(project); await generateReadme(project); + await generateAssemblyInfo(project); await generateScriptCmdlets(project); diff --git a/powershell/resources/assets/build-module.ps1 b/powershell/resources/assets/build-module.ps1 index 3d450b4d28..ed01dbac5c 100644 --- a/powershell/resources/assets/build-module.ps1 +++ b/powershell/resources/assets/build-module.ps1 @@ -80,13 +80,6 @@ if(-not $Debugger) { $null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path (Join-Path $binFolder 'Debug'), (Join-Path $binFolder 'Release') } -if ($isAzure -And '${$project.assemblyInfoPath}') { - $assemblyInfoPath = Join-Path $PSScriptRoot '${$project.assemblyInfoPath}' - $header = '${$project.csharpCommentHeaderForCsharp}' - $content = $header + [Environment]::NewLine + [Environment]::NewLine + (Get-Content $assemblyInfoPath -Raw) - $content | Set-Content $assemblyInfoPath -Force -} - $dll = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.dll)}' if(-not (Test-Path $dll)) { Write-Error "Unable to find output assembly in '$binFolder'."