зеркало из https://github.com/dotnet/pinvoke.git
Update templates
This commit is contained in:
Родитель
e2f57ae1c2
Коммит
a030e8bcba
|
@ -8,7 +8,10 @@ Please send pull requests to add what you've come up with.
|
|||
|
||||
### Required
|
||||
|
||||
* [Visual Studio 2017](https://www.visualstudio.com/en-us)
|
||||
* [Visual Studio 2017](https://www.visualstudio.com/en-us) with the following workloads:
|
||||
* Desktop Development with C++
|
||||
* Desktop Development with .NET
|
||||
* .NET Core
|
||||
|
||||
## Guidelines
|
||||
|
||||
|
|
|
@ -20,44 +20,12 @@ param(
|
|||
[Parameter(Mandatory=$true,Position=0)]
|
||||
[string]$CoreLibraryName
|
||||
)
|
||||
function Replace-Placeholders {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Path,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$LibraryName,
|
||||
[Parameter(Mandatory=$true)]
|
||||
$Replacements
|
||||
)
|
||||
|
||||
Get-ChildItem -Recurse $Path -File |% {
|
||||
$content = Get-Content -Path $_.FullName
|
||||
$Replacements.GetEnumerator() |% { $content = $content -replace $_.Key,$_.Value }
|
||||
Set-Content -Path $_.FullName -Value $content -Encoding UTF8
|
||||
|
||||
if ($_.Name -match 'LIBNAME') {
|
||||
$NewLeafName = $_.Name -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $_.FullName $NewLeafName
|
||||
}
|
||||
}
|
||||
|
||||
# Rename directories
|
||||
Get-ChildItem -Recurse $Path -Directory |% {
|
||||
if ($_.Name -match 'LIBNAME') {
|
||||
$NewLeafName = $_.Name -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $_.FullName $NewLeafName
|
||||
}
|
||||
}
|
||||
|
||||
# Finally, rename $Path itself
|
||||
$NewLeafName = (Split-Path -Leaf $Path) -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $Path $NewLeafName
|
||||
}
|
||||
. $PSScriptRoot\Replace-Placeholders.ps1
|
||||
|
||||
$Src = Resolve-Path "$PSScriptRoot\..\src"
|
||||
|
||||
$Directories = 'LIBNAME','LIBNAME.Profile111','LIBNAME.Desktop','LIBNAME.Shared','LIBNAME.NuGet'
|
||||
$Directories = ,'LIBNAME'
|
||||
$TemplateDirectories = @()
|
||||
$SrcDirectories = @()
|
||||
foreach($dir in $Directories) {
|
||||
|
@ -71,12 +39,6 @@ foreach($dir in $Directories) {
|
|||
}
|
||||
|
||||
$Replacements = @{
|
||||
'\$guid1\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid2\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid3\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid4\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid5\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid6\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'LIBNAME' = $CoreLibraryName;
|
||||
}
|
||||
|
||||
|
@ -84,12 +46,8 @@ Copy-Item -Recurse -Path $TemplateDirectories -Destination $Src
|
|||
$SrcDirectories |% { Replace-Placeholders -LibraryName $CoreLibraryName -Replacements $Replacements -Path $_ }
|
||||
|
||||
Write-Output "Great. Your new projects have been created. Please also perform a few more manual steps:"
|
||||
Write-Output "1. Add these new projects to your solution file:"
|
||||
Write-Output "1. Add this new project to your solution file:"
|
||||
Write-Output " $Src\$CoreLibraryName\$CoreLibraryName.csproj"
|
||||
Write-Output " $Src\$CoreLibraryName.Profile111\$CoreLibraryName.Profile111.csproj"
|
||||
Write-Output " $Src\$CoreLibraryName.Desktop\$CoreLibraryName.Desktop.csproj"
|
||||
Write-Output " $Src\$CoreLibraryName.Shared\$CoreLibraryName.Shared.shproj"
|
||||
Write-Output " $Src\$CoreLibraryName.NuGet\$CoreLibraryName.NuGet.nuproj"
|
||||
Write-Output "2. Add your library to the README.md file."
|
||||
Write-Output "3. Add a project reference to $Src\$CoreLibraryName.NuGet\$CoreLibraryName.NuGet.nuproj"
|
||||
Write-Output " into the PInvoke.Win32.nuproj project, if it's part of the Win32 API."
|
||||
Write-Output "3. Add a project reference to $Src\$CoreLibraryName\$CoreLibraryName.csproj"
|
||||
Write-Output " into the Win32 project, if it's part of the Win32 API."
|
||||
|
|
|
@ -14,44 +14,17 @@ param(
|
|||
[Parameter(Mandatory=$true,Position=0)]
|
||||
[string]$LibraryName
|
||||
)
|
||||
function Replace-Placeholders {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Path,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$LibraryName,
|
||||
[Parameter(Mandatory=$true)]
|
||||
$Replacements
|
||||
)
|
||||
|
||||
Get-ChildItem -Recurse $Path -File |% {
|
||||
$content = Get-Content -Path $_.FullName
|
||||
$Replacements.GetEnumerator() |% { $content = $content -replace $_.Key,$_.Value }
|
||||
Set-Content -Path $_.FullName -Value $content -Encoding UTF8
|
||||
|
||||
if ($_.Name -match 'LIBNAME') {
|
||||
$NewLeafName = $_.Name -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $_.FullName $NewLeafName
|
||||
}
|
||||
}
|
||||
|
||||
# Rename directories
|
||||
Get-ChildItem -Recurse $Path -Directory |% {
|
||||
if ($_.Name -match 'LIBNAME') {
|
||||
$NewLeafName = $_.Name -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $_.FullName $NewLeafName
|
||||
}
|
||||
}
|
||||
|
||||
# Finally, rename $Path itself
|
||||
$NewLeafName = (Split-Path -Leaf $Path) -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $Path $NewLeafName
|
||||
if (!(Get-Command dumpbin)) {
|
||||
Write-Error "DUMPBIN must be on your path. Install the `"Desktop Development with C++`" workload and repeat this command within a VS 2017 Developer Command Prompt."
|
||||
return 1
|
||||
}
|
||||
|
||||
. $PSScriptRoot\Replace-Placeholders.ps1
|
||||
|
||||
$Src = Resolve-Path "$PSScriptRoot\..\src"
|
||||
|
||||
$Directories = 'LIBNAME','LIBNAME.Profile111','LIBNAME.Desktop','LIBNAME.Shared','LIBNAME.Tests','LIBNAME.NuGet'
|
||||
$Directories = 'LIBNAME','LIBNAME.Tests'
|
||||
$TemplateDirectories = @()
|
||||
$SrcDirectories = @()
|
||||
foreach($dir in $Directories) {
|
||||
|
@ -65,28 +38,18 @@ foreach($dir in $Directories) {
|
|||
}
|
||||
|
||||
$Replacements = @{
|
||||
'\$guid1\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid2\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid3\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid4\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid5\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'\$guid6\$' = [Guid]::NewGuid().ToString('b').ToUpper();
|
||||
'LIBNAME' = $LibraryName;
|
||||
}
|
||||
|
||||
Copy-Item -Recurse -Path $TemplateDirectories -Destination $Src
|
||||
$SrcDirectories |% { Replace-Placeholders -LibraryName $LibraryName -Replacements $Replacements -Path $_ }
|
||||
|
||||
& "$PSScriptRoot\CreateExportsTxtFile.ps1" -AssemblyPath "$env:windir\System32\$LibraryName.dll" -OutputDir "$Src\$LibraryName.Desktop\"
|
||||
& "$PSScriptRoot\CreateExportsTxtFile.ps1" -AssemblyPath "$env:windir\System32\$LibraryName.dll" -OutputDir "$Src\$LibraryName\"
|
||||
|
||||
Write-Output "Great. Your new projects have been created. Please also perform a few more manual steps:"
|
||||
Write-Output "1. Add these new projects to your solution file:"
|
||||
Write-Output " $Src\$LibraryName\$LibraryName.csproj"
|
||||
Write-Output " $Src\$LibraryName.Profile111\$LibraryName.Profile111.csproj"
|
||||
Write-Output " $Src\$LibraryName.Desktop\$LibraryName.Desktop.csproj"
|
||||
Write-Output " $Src\$LibraryName.Shared\$LibraryName.Shared.shproj"
|
||||
Write-Output " $Src\$LibraryName.Tests\$LibraryName.Tests.csproj"
|
||||
Write-Output " $Src\$LibraryName.NuGet\$LibraryName.NuGet.nuproj"
|
||||
Write-Output "2. Add your library to the README.md file."
|
||||
Write-Output "3. Add a project reference to $Src\$LibraryName.NuGet\$LibraryName.NuGet.nuproj"
|
||||
Write-Output " into the PInvoke.Win32.nuproj project, if it's part of the Win32 API."
|
||||
Write-Output "3. Add a project reference to $Src\$CoreLibraryName\$CoreLibraryName.csproj"
|
||||
Write-Output " into the Win32 project, if it's part of the Win32 API."
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Windows.Core\Windows.Core.csproj" />
|
||||
<ProjectReference Include="..\LIBNAME\LIBNAME.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
|
||||
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
[assembly: AssemblyTitle("PInvoke.LIBNAME.Tests")]
|
||||
[assembly: AssemblyProduct("PInvoke.LIBNAME.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
|
@ -0,0 +1,34 @@
|
|||
function Replace-Placeholders {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Path,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$LibraryName,
|
||||
[Parameter(Mandatory=$true)]
|
||||
$Replacements
|
||||
)
|
||||
|
||||
Get-ChildItem -Recurse $Path -File |% {
|
||||
$content = Get-Content -Path $_.FullName
|
||||
$Replacements.GetEnumerator() |% { $content = $content -replace $_.Key,$_.Value }
|
||||
Set-Content -Path $_.FullName -Value $content -Encoding UTF8
|
||||
|
||||
if ($_.Name -match 'LIBNAME') {
|
||||
$NewLeafName = $_.Name -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $_.FullName $NewLeafName
|
||||
}
|
||||
}
|
||||
|
||||
# Rename directories
|
||||
Get-ChildItem -Recurse $Path -Directory |% {
|
||||
if ($_.Name -match 'LIBNAME') {
|
||||
$NewLeafName = $_.Name -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $_.FullName $NewLeafName
|
||||
}
|
||||
}
|
||||
|
||||
# Finally, rename $Path itself
|
||||
$NewLeafName = (Split-Path -Leaf $Path) -Replace 'LIBNAME',$LibraryName
|
||||
Rename-Item $Path $NewLeafName
|
||||
}
|
Загрузка…
Ссылка в новой задаче