mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Adjusting generation commands to new data migration path and file names
--HG-- branch : dev
This commit is contained in:
parent
8162e6ee7a
commit
9696efe4bb
@ -7,7 +7,7 @@ using Orchard.Core.Contents.Extensions;
|
|||||||
using Orchard.Data.Migration;
|
using Orchard.Data.Migration;
|
||||||
|
|
||||||
namespace $$FeatureName$$.DataMigrations {
|
namespace $$FeatureName$$.DataMigrations {
|
||||||
public class $$ClassName$$DataMigration : DataMigrationImpl {
|
public class Migration : DataMigrationImpl {
|
||||||
|
|
||||||
public int Create() {
|
public int Create() {
|
||||||
$$Commands$$
|
$$Commands$$
|
||||||
|
@ -65,16 +65,16 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string dataMigrationsPath = HostingEnvironment.MapPath("~/Modules/" + extensionDescriptor.Name + "/DataMigrations/");
|
string dataMigrationFolderPath = HostingEnvironment.MapPath("~/Modules/" + extensionDescriptor.Name + "/");
|
||||||
string dataMigrationPath = dataMigrationsPath + extensionDescriptor.DisplayName + "DataMigration.cs";
|
string dataMigrationFilePath = dataMigrationFolderPath + "Migration.cs";
|
||||||
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
|
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
|
||||||
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extensionDescriptor.Name));
|
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extensionDescriptor.Name));
|
||||||
|
|
||||||
if (!Directory.Exists(dataMigrationsPath)) {
|
if (!Directory.Exists(dataMigrationFolderPath)) {
|
||||||
Directory.CreateDirectory(dataMigrationsPath);
|
Directory.CreateDirectory(dataMigrationFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(dataMigrationPath)) {
|
if (File.Exists(dataMigrationFilePath)) {
|
||||||
Context.Output.WriteLine(T("Data migration already exists in target Module {0}.", extensionDescriptor.Name));
|
Context.Output.WriteLine(T("Data migration already exists in target Module {0}.", extensionDescriptor.Name));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -91,9 +91,8 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
|
|
||||||
string dataMigrationText = File.ReadAllText(templatesPath + "DataMigration.txt");
|
string dataMigrationText = File.ReadAllText(templatesPath + "DataMigration.txt");
|
||||||
dataMigrationText = dataMigrationText.Replace("$$FeatureName$$", featureName);
|
dataMigrationText = dataMigrationText.Replace("$$FeatureName$$", featureName);
|
||||||
dataMigrationText = dataMigrationText.Replace("$$ClassName$$", extensionDescriptor.DisplayName);
|
|
||||||
dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString());
|
dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString());
|
||||||
File.WriteAllText(dataMigrationPath, dataMigrationText);
|
File.WriteAllText(dataMigrationFilePath, dataMigrationText);
|
||||||
|
|
||||||
string projectFileText = File.ReadAllText(moduleCsProjPath);
|
string projectFileText = File.ReadAllText(moduleCsProjPath);
|
||||||
|
|
||||||
@ -370,6 +369,7 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var projectText = File.ReadAllText(_orchardWebProj);
|
var projectText = File.ReadAllText(_orchardWebProj);
|
||||||
|
|
||||||
// find where the first ItemGroup is after any References
|
// find where the first ItemGroup is after any References
|
||||||
var refIndex = projectText.LastIndexOf("<Reference Include");
|
var refIndex = projectText.LastIndexOf("<Reference Include");
|
||||||
if (refIndex != -1) {
|
if (refIndex != -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user