2017-07-18 48 views

回答

0

您可以使用下面的功能,這將有助於你在改變:

以下是參考鏈接:

1)Link 1

2)Link 2

function Rename-Project 
{ 
# designed to run from the src folder 
param(
    [string]$projectName=$(throw "projectName required."), 
    [string]$newProjectName=$(throw "newProjectName required.") 
) 

if(!(Test-Path $projectName)){ 
    Write-Error "No project folder '$projectName' found" 
    return 
} 

if(!(Test-Path $projectName\$projectName.csproj)){ 
    Write-Error "No project '$projectName\$projectName.dll' found" 
    return 
} 

if((Test-Path $newProjectName)){ 
    Write-Error "Project '$newProjectName' already exists" 
    return 
} 

# project 
hg rename $projectName\$projectName.csproj $projectName\$newProjectName.csproj 

# folder 
hg rename $projectName $newProjectName 

# assembly title 
$assemblyInfoPath = "$newProjectName\Properties\AssemblyInfo.cs" 
(gc $assemblyInfoPath) -replace """$projectName""","""$newProjectName""" | sc $assemblyInfoPath 

# root namespace 
$projectFile = "$newProjectName\$newProjectName.csproj" 
(gc $projectFile) -replace "<RootNamespace>$projectName</RootNamespace>","<RootNamespace>$newProjectName</RootNamespace>" | sc $projectFile 

# assembly name 
(gc $projectFile) -replace "<AssemblyName>$projectName</AssemblyName>","<AssemblyName>$newProjectName</AssemblyName>" | sc $projectFile 

# other project references 
gci -Recurse -Include *.csproj |% { (gc $_) -replace "..\\$projectName\\$projectName.csproj", "..\$newProjectName\$newProjectName.csproj" | sc $_ } 
gci -Recurse -Include *.csproj |% { (gc $_) -replace "<Name>$projectName</Name>", "<Name>$newProjectName</Name>" | sc $_ } 

# solution 
gci -Recurse -Include *.sln |% { (gc $_) -replace "\""$projectName\""", """$newProjectName""" | sc $_ } 
gci -Recurse -Include *.sln |% { (gc $_) -replace "\""$projectName\\$projectName.csproj\""", """$newProjectName\$newProjectName.csproj""" | sc $_ } 
} 
+0

Ranadip杜塔,感謝您對此事的時間和考慮。我正在和我的團隊討論這個解決方案。這聽起來像一個好方法。 – Carlos

相關問題