Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                int argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                    edmxName = null;
                else
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                string projectDirectoryPath = args[argIndex++];
                string toolsClientWPFPath = args[argIndex++];
                string rootNamespace = args[argIndex++];
                string svcUrl = args[argIndex++];
                string waqsDirectory = args[argIndex++];
                string waqsGeneralDirectory = args[argIndex++];
                string expressionTransformerPath = args[argIndex++];
                string serviceContractPath = args[argIndex++];
                string entitiesPath = args[argIndex++];
                string clientContextPath = args[argIndex++];
                string clientContextInterfacesPath = args[argIndex++];
                string serverEntitiesSolutionPath = args[argIndex++];
                string serverEntitiesProjectPath = args[argIndex++];
                string netVersion = args[argIndex++];
                string vsVersion = args[argIndex++];
                string kind = args[argIndex++];
                bool sourceControl = args[argIndex++] == "WithSourceControl";
                string slnFilePath = args[argIndex++];
                string slnTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "WPFClientTemplates");
                string serverEntitiesFolderPath = null;
                string specificationsSlnFilePath = slnFilePath;
                string specificationsCsprojPath = null;
                string specificationsFolderPath = null;
                string dtoSlnFilePath = null;
                string dtoCsprojPath = null;
                string dtoFolderPath = null;
                string serverEntitiesNamespace = null;

                if (kind == "All" || kind == "WithoutFramework" || kind == "WithoutGlobal" || kind == "WithoutGlobalWithoutFramework")
                {
                    dtoSlnFilePath = specificationsSlnFilePath;
                    specificationsCsprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoCsprojPath = args[argIndex++];
                    dtoFolderPath = args[argIndex++];
                    var edmxDirectoryPath = Path.GetDirectoryName(edmxPath);
                    if (edmxDirectoryPath == Path.GetDirectoryName(serverEntitiesProjectPath))
                    {
                        if (Directory.Exists(specificationsFolderPath = Path.Combine(edmxDirectoryPath, "Specifications")))
                            specificationsCsprojPath = serverEntitiesProjectPath;
                        if (Directory.Exists(dtoFolderPath = Path.Combine(edmxDirectoryPath, "DTO")))
                            dtoCsprojPath = serverEntitiesProjectPath;
                    }
                    serverEntitiesFolderPath = Path.GetDirectoryName(args[argIndex]);
                    string entityContent;
                    using (var sr = new StreamReader(args[argIndex]))
                    {
                        entityContent = sr.ReadToEnd();
                    }
                    serverEntitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entityContent));
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    string serviceContractNamespace = null;
                    string entitiesNamespace = null;
                    string clientContextNamespace = null;
                    string clientContextInterfacesNamespace = null;
                    if (kind == "GlobalOnly" && !(string.IsNullOrEmpty(expressionTransformerPath) || string.IsNullOrEmpty(serviceContractPath) || string.IsNullOrEmpty(entitiesPath) || string.IsNullOrEmpty(clientContextPath) || string.IsNullOrEmpty(clientContextInterfacesPath)))
                    {
                        string expressionTransformerContent;
                        using (var sr = new StreamReader(expressionTransformerPath))
                        {
                            expressionTransformerContent = sr.ReadToEnd();
                        }
                        string serviceContractContent;
                        using (var sr = new StreamReader(serviceContractPath))
                        {
                            serviceContractContent = sr.ReadToEnd();
                        }
                        serviceContractNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(serviceContractContent));
                        string entitiesContent;
                        using (var sr = new StreamReader(entitiesPath))
                        {
                            entitiesContent = sr.ReadToEnd();
                        }
                        entitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entitiesContent));
                        string clientContextContent;
                        using (var sr = new StreamReader(clientContextPath))
                        {
                            clientContextContent = sr.ReadToEnd();
                        }
                        clientContextNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextContent));
                        string clientContextInterfacesContent;
                        using (var sr = new StreamReader(clientContextInterfacesPath))
                        {
                            clientContextInterfacesContent = sr.ReadToEnd();
                        }
                        clientContextInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextInterfacesContent));
                    }

                    if (kind == "All" || kind == "WithoutFramework" || kind == "GlobalOnly")
                    {
                        if (kind == "GlobalOnly")
                        {
                            string contextsFilePath = Path.Combine(waqsGeneralDirectory, "Contexts.xml");
                            if (Directory.Exists(waqsGeneralDirectory))
                            {
                                if (File.Exists(contextsFilePath))
                                {
                                    var contexts = XElement.Load(contextsFilePath);
                                    contexts.Add(
                                        XElement.Parse(
                                            string.Format(
                                                "<Context Name=\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.WPF.waqs\" />",
                                                edmxName)));
                                    contexts.Save(contextsFilePath);
                                }
                            }
                            else
                            {
                                Directory.CreateDirectory(waqsGeneralDirectory);
                                using (var sw = new StreamWriter(contextsFilePath))
                                {
                                    sw.WriteLine(string.Concat(
                                        @"<Contexts>
            <Context Name=", "\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.WPF.waqs\" />", @"
            </Contexts>"), edmxName);
                                }
                            }
                        }
                        string appXamlFilePath = Path.Combine(projectDirectoryPath, "App.xaml");
                        XElement appXaml = XElement.Load(appXamlFilePath);
                        string appXamlCsFilePath = Path.Combine(projectDirectoryPath, "App.xaml.cs");
                        if (appXaml != null)
                        {
                            string appXamlCsContent;
                            using (var sr = new StreamReader(appXamlCsFilePath))
                            {
                                appXamlCsContent = sr.ReadToEnd();
                            }
                            if (string.IsNullOrEmpty(clientContextNamespace))
                                clientContextNamespace = rootNamespace + ".ClientContext";
                            if (string.IsNullOrEmpty(clientContextInterfacesNamespace))
                                clientContextInterfacesNamespace = rootNamespace + ".ClientContext.Interfaces";
                            XAttribute startupUri = appXaml.Attribute("StartupUri");
                            if (startupUri != null)
                            {
                                string pageXamlFile = startupUri.Value;
                                string pageTypeName = XElement.Load(Path.Combine(projectDirectoryPath, pageXamlFile)).Attribute(XName.Get("Class", "http://schemas.microsoft.com/winfx/2006/xaml")).Value;
                                startupUri.Remove();
                                appXaml.Save(appXamlFilePath);

                                appXamlCsContent = new ApplicationStartupRewriter(edmxName, rootNamespace, clientContextNamespace, clientContextInterfacesNamespace, pageTypeName).Visit(SyntaxFactory.ParseCompilationUnit(appXamlCsContent)).NormalizeWhitespace().ToString();
                            }
                            else
                            {
                                appXamlCsContent = new ApplicationStartupRewriter(edmxName, rootNamespace, clientContextNamespace, clientContextInterfacesNamespace, first: false).Visit(SyntaxFactory.ParseCompilationUnit(appXamlCsContent)).NormalizeWhitespace().ToString();
                            }
                            using (var sw = new StreamWriter(appXamlCsFilePath))
                            {
                                sw.Write(appXamlCsContent);
                            }
                        }

                        string appFilePath = Path.Combine(projectDirectoryPath, "app.config");
                        if (!File.Exists(appFilePath))
                            CopyFile(Path.Combine(toolsClientWPFPath, "app.config"), appFilePath);

                        XElement clientConfig = XElement.Load(appFilePath);
                        XElement serviceModel = clientConfig.Element("system.serviceModel");
                        XElement bindings;
                        XElement customBinding;
                        if (serviceModel == null)
                            clientConfig.Add(serviceModel = new XElement("system.serviceModel", new XElement("bindings", customBinding = new XElement("customBinding"))));
                        else if ((bindings = serviceModel.Element("bindings")) == null)
                            serviceModel.Add(new XElement("bindings", customBinding = new XElement("customBinding")));
                        else if ((customBinding = bindings.Element("customBinding")) == null)
                            bindings.Add(customBinding = new XElement("customBinding"));

                        customBinding.Add(
                            new XElement("binding",
                                new XAttribute("name", string.Format("CustomBinding_I{0}Service", edmxName)),
                                new XElement("binaryMessageEncoding",
                                    new XAttribute("maxReadPoolSize", "2147483647"),
                                    new XAttribute("maxWritePoolSize", "2147483647"),
                                    new XAttribute("maxSessionSize", "2147483647"),
                                    new XElement("readerQuotas",
                                        new XAttribute("maxDepth", "2147483647"),
                                        new XAttribute("maxStringContentLength", "2147483647"),
                                        new XAttribute("maxArrayLength", "2147483647"),
                                        new XAttribute("maxBytesPerRead", "2147483647"),
                                        new XAttribute("maxNameTableCharCount", "2147483647"))),
                                new XElement("httpTransport",
                                    new XAttribute("manualAddressing", "false"),
                                    new XAttribute("maxBufferPoolSize", "2147483647"),
                                    new XAttribute("maxReceivedMessageSize", "2147483647"),
                                    new XAttribute("allowCookies", "false"),
                                    new XAttribute("authenticationScheme", "Anonymous"),
                                    new XAttribute("bypassProxyOnLocal", "false"),
                                    new XAttribute("decompressionEnabled", "true"),
                                    new XAttribute("hostNameComparisonMode", "StrongWildcard"),
                                    new XAttribute("keepAliveEnabled", "true"),
                                    new XAttribute("maxBufferSize", "2147483647"),
                                    new XAttribute("proxyAuthenticationScheme", "Anonymous"),
                                    new XAttribute("realm", ""),
                                    new XAttribute("transferMode", "Buffered"),
                                    new XAttribute("unsafeConnectionNtlmAuthentication", "false"),
                                    new XAttribute("useDefaultWebProxy", "true"))));
                        XElement client;
                        if ((client = serviceModel.Element("client")) == null)
                            serviceModel.Add(client = new XElement("client"));
                        client.Add(
                            new XElement("endpoint",
                                new XAttribute("address", svcUrl),
                                new XAttribute("binding", "customBinding"),
                                new XAttribute("bindingConfiguration", string.Format("CustomBinding_I{0}Service", edmxName)),
                                new XAttribute("contract", string.Format("{0}.I{1}Service", serviceContractNamespace ?? (rootNamespace + ".ClientContext.ServiceReference"), edmxName)),
                                new XAttribute("name", string.Format("CustomBinding_I{0}Service", edmxName))));
                        clientConfig.Save(appFilePath);
                    }

                    Directory.CreateDirectory(waqsDirectory);

                    string toolsWaqsPath = null;
                    switch (kind)
                    {
                        case "All":
                        case "WithoutGlobal":
                            toolsWaqsPath = Path.Combine(toolsClientWPFPath, "Client.WPF.waqs");
                            break;
                        case "WithoutFramework":
                        case "WithoutGlobalWithoutFramework":
                            toolsWaqsPath = Path.Combine(toolsClientWPFPath, "ClientWithoutFramework.WPF.waqs");
                            break;
                        case "FrameworkOnly":
                            toolsWaqsPath = Path.Combine(toolsClientWPFPath, "ClientFrameworkOnly.WPF.waqs");
                            edmxName = "Framework";
                            break;
                        case "GlobalOnly":
                            toolsWaqsPath = Path.Combine(toolsClientWPFPath, "ClientGlobalOnly.WPF.waqs");
                            break;
                    }
                    string clientWPFWAQS = Path.Combine(waqsDirectory, edmxName + ".Client.WPF.waqs");
                    if (toolsWaqsPath != null)
                    {
                        if (!File.Exists(clientWPFWAQS))
                        {
                            serverEntitiesSolutionPath = GetRelativePath(serverEntitiesSolutionPath, waqsDirectory);
                            serverEntitiesProjectPath = GetRelativePath(serverEntitiesProjectPath, waqsDirectory);
                            var slnRelativeFilePath = GetRelativePath(slnFilePath, waqsDirectory);
                            specificationsCsprojPath = GetRelativePath(specificationsCsprojPath, waqsDirectory);
                            specificationsFolderPath = GetRelativePath(specificationsFolderPath, waqsDirectory);
                            serverEntitiesFolderPath = GetRelativePath(serverEntitiesFolderPath, waqsDirectory);
                            dtoSlnFilePath = GetRelativePath(dtoSlnFilePath, waqsDirectory);
                            dtoCsprojPath = GetRelativePath(dtoCsprojPath, waqsDirectory);
                            dtoFolderPath = GetRelativePath(dtoFolderPath, waqsDirectory);
                            CopyFile(toolsWaqsPath, clientWPFWAQS, new[] { "$edmxPath$", edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$svcUrl$", svcUrl }, new[] { "$EntitiesNamespace$", entitiesNamespace }, new[] { "$ClientContextNamespace$", clientContextNamespace }, new[] { "$ClientContextInterfacesNamespace$", clientContextInterfacesNamespace }, new[] { "$SpecificationsSlnFilePath$", slnRelativeFilePath }, new[] { "$SpecificationsCsprojPath$", specificationsCsprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", dtoSlnFilePath }, new[] { "$DTOCsprojPath$", dtoCsprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$ServerEntitiesSlnFilePath$", serverEntitiesSolutionPath }, new[] { "$ServerEntitiesCsprojPath$", serverEntitiesProjectPath }, new[] { "$ServerEntitiesFolderPath$", serverEntitiesFolderPath + "\\" }, new[] { "$ServerEntitiesNamespace$", serverEntitiesNamespace });
                        }

                        if (kind != "GlobalOnly")
                        {
                            string clientWPFTT = Path.Combine(waqsDirectory, edmxName + ".Client.WPF.tt");
                            if (!File.Exists(clientWPFTT))
                                CopyTTFile(Path.Combine(toolsClientWPFPath, "Client.WPF.tt"), clientWPFTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                        }
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath = Path.Combine(Path.GetDirectoryName(toolsClientWPFPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "WPFClientTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            bool addGlobalService = false;

            try
            {
                int    argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                {
                    edmxPath = null;
                    edmxName = null;
                }
                else
                {
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                }
                string edmxProjectPath      = args[argIndex++];
                string projectDirectoryPath = args[argIndex++];
                string toolsServerPath      = args[argIndex++];
                string rootNamespace        = args[argIndex++];
                string assemblyName         = args[argIndex++];
                string assemblyVersion      = args[argIndex++];
                string netVersion           = args[argIndex++];
                string vsVersion            = args[argIndex++];
                string kind              = args[argIndex++];
                string appKind           = args[argIndex++];
                string waqsDirectory     = args[argIndex++];
                string appConfigPath     = args[argIndex++];
                bool   sourceControl     = args[argIndex++] == "WithSourceControl";
                string slnFilePath       = args[argIndex++];
                bool   isWCF             = args[argIndex++] == "WCF";
                string slnTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerTemplates");

                string dalInterfacesNamespace      = null;
                string dalNamespace                = null;
                string serviceInterfacesNamespace  = null;
                string serviceNamespace            = null;
                string wcfServiceContractNamespace = null;
                string wcfServiceNamespace         = null;
                string csprojPath = null;
                string specificationsFolderPath = null;
                string dtoFolderPath            = null;

                string assemblyNetVersion = null;
                switch (netVersion)
                {
                case "NET40":
                    assemblyVersion = "4.0";
                    break;

                case "NET45":
                    assemblyNetVersion = "4.5";
                    break;

                case "NET46":
                    assemblyNetVersion = "4.6";
                    break;

                default:
                    throw new NotImplementedException();
                }

                if (kind == "GlobalOnly")
                {
                    string dalInterfaces;
                    using (StreamReader sr = new StreamReader(args[argIndex++]))
                    {
                        dalInterfaces = sr.ReadToEnd();
                    }
                    dalInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dalInterfaces));
                    string dalFileName = args[argIndex++];
                    if (!string.IsNullOrEmpty(dalFileName))
                    {
                        string dal;
                        using (StreamReader sr = new StreamReader(dalFileName))
                        {
                            dal = sr.ReadToEnd();
                        }
                        dalNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dal));
                    }
                    string serviceInterfacesFileName = args[argIndex++];
                    if (!string.IsNullOrEmpty(serviceInterfacesFileName))
                    {
                        string serviceInterfaces;
                        using (StreamReader sr = new StreamReader(serviceInterfacesFileName))
                        {
                            serviceInterfaces = sr.ReadToEnd();
                        }
                        serviceInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(serviceInterfaces));
                    }
                    string serviceFileName = args[argIndex++];
                    if (!string.IsNullOrEmpty(serviceFileName))
                    {
                        string service;
                        using (StreamReader sr = new StreamReader(serviceFileName))
                        {
                            service = sr.ReadToEnd();
                        }
                        serviceNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(service));
                    }
                    if (isWCF)
                    {
                        string wcfServiceContractFileName = args[argIndex++];
                        if (!string.IsNullOrEmpty(wcfServiceContractFileName))
                        {
                            string wcfServiceContract;
                            using (StreamReader sr = new StreamReader(wcfServiceContractFileName))
                            {
                                wcfServiceContract = sr.ReadToEnd();
                            }
                            wcfServiceContractNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(wcfServiceContract));
                        }
                        string wcfServiceFileName = args[argIndex++];
                        if (!string.IsNullOrEmpty(wcfServiceFileName))
                        {
                            string wcfService;
                            using (StreamReader sr = new StreamReader(wcfServiceFileName))
                            {
                                wcfService = sr.ReadToEnd();
                            }
                            wcfServiceNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(wcfService));
                        }
                        string globalDirectoryPath = Path.Combine(projectDirectoryPath, "Global");
                        if (Directory.Exists(globalDirectoryPath))
                        {
                            string globalWCFServicePath = Path.Combine(globalDirectoryPath, "GlobalWCFService.cs");
                            if (File.Exists(globalWCFServicePath))
                            {
                                string globalWCFServiceContent;
                                using (var sr = new StreamReader(globalWCFServicePath))
                                {
                                    globalWCFServiceContent = sr.ReadToEnd();
                                }
                                using (var sw = new StreamWriter(globalWCFServicePath))
                                {
                                    sw.WriteLine(new GlobalWCFServiceRewriter(edmxName).Visit(SyntaxFactory.ParseCompilationUnit(globalWCFServiceContent)).NormalizeWhitespace().ToString());
                                }
                            }
                        }
                        else
                        {
                            addGlobalService = true;
                            Directory.CreateDirectory(globalDirectoryPath);
                            using (var sw = new StreamWriter(Path.Combine(globalDirectoryPath, "GlobalWCFService.cs")))
                            {
                                sw.WriteLine(string.Concat(
                                                 @"using System.Transactions;

    namespace ", rootNamespace, @"
    {
        public partial class GlobalWCFService : IGlobalWCFService
        {
            public GlobalSerializedContexts SaveChanges(GlobalSerializedContexts clientContexts)
            {
                using (var transaction = new TransactionScope())
                {
                    ", edmxName, @"SaveChanges(clientContexts);
                    transaction.Complete();
                    return clientContexts;
                }
            }
        }
    }"));
                            }
                            string globalTTFilePath = Path.Combine(globalDirectoryPath, "GlobalWCFServiceContract.tt");
                            if (!File.Exists(globalTTFilePath))
                            {
                                CopyTTFile(Path.Combine(toolsServerPath, "Server.Global.tt"), globalTTFilePath, sourceControl, slnTTIncludesPath, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                            }

                            using (var sw = new StreamWriter(Path.Combine(projectDirectoryPath, "Global.svc")))
                            {
                                sw.WriteLine(string.Concat("<%@ ServiceHost Language=\"C#\" Service=\"", rootNamespace, ".GlobalWCFService\" %>"));
                            }
                        }
                    }
                }

                if (kind != "FrameworkOnly")
                {
                    csprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoFolderPath            = args[argIndex++];
                    if (kind != "GlobalOnly")
                    {
                        Directory.CreateDirectory(specificationsFolderPath);
                        Directory.CreateDirectory(dtoFolderPath);
                    }
                }

                if (kind == "All" || kind == "WithoutFramework" || kind == "GlobalOnly")
                {
                    if (appKind == "App")
                    {
                        WriteAppGlobal(edmxPath, edmxName, edmxProjectPath, projectDirectoryPath, toolsServerPath, rootNamespace, assemblyName, assemblyVersion, appConfigPath, addGlobalService);
                    }
                    else
                    {
                        WriteWebGlobal(edmxPath, edmxName, edmxProjectPath, projectDirectoryPath, toolsServerPath, rootNamespace, assemblyNetVersion, assemblyName, assemblyVersion, wcfServiceNamespace, appConfigPath, addGlobalService, isWCF);
                    }
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    Directory.CreateDirectory(waqsDirectory);

                    string waqsToolsPath = null;
                    switch (kind)
                    {
                    case "All":
                        waqsToolsPath = Path.Combine(toolsServerPath, "Server.waqs");
                        break;

                    case "WithoutGlobal":
                        waqsToolsPath = Path.Combine(toolsServerPath, "ServerWithoutGlobal.waqs");
                        break;

                    case "WithoutFramework":
                        waqsToolsPath = Path.Combine(toolsServerPath, "ServerWithoutFramework.waqs");
                        break;

                    case "WithoutGlobalWithoutFramework":
                        waqsToolsPath = Path.Combine(toolsServerPath, "ServerWithoutGlobalWithoutFramework.waqs");
                        break;

                    case "FrameworkOnly":
                        waqsToolsPath = Path.Combine(toolsServerPath, "ServerFrameworkOnly.waqs");
                        edmxName      = "Framework";
                        break;

                    case "GlobalOnly":
                        waqsToolsPath = Path.Combine(toolsServerPath, "ServerGlobalOnly.waqs");
                        break;
                    }
                    string serverWAQS = Path.Combine(waqsDirectory, edmxName + ".Server.waqs");
                    if (!File.Exists(serverWAQS))
                    {
                        csprojPath = GetRelativePath(csprojPath, waqsDirectory);
                        var slnRelativeFilePath = GetRelativePath(slnFilePath, waqsDirectory);
                        specificationsFolderPath = GetRelativePath(specificationsFolderPath, waqsDirectory);
                        dtoFolderPath            = GetRelativePath(dtoFolderPath, waqsDirectory);
                        CopyFile(waqsToolsPath, serverWAQS, new[] { "$edmxPath$", edmxPath == null ? null : edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$DALInterfacesNamespace$", dalInterfacesNamespace }, new[] { "$DALNamespace$", dalNamespace }, new[] { "$ServiceInterfacesNamespace$", serviceInterfacesNamespace }, new[] { "$ServiceNamespace$", serviceNamespace }, new[] { "$WCFServiceContractNamespace$", wcfServiceContractNamespace }, new[] { "$WCFServiceNamespace$", wcfServiceNamespace }, new[] { "$SpecificationsSlnFilePath$", slnRelativeFilePath }, new[] { "$SpecificationsCsprojPath$", csprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", slnRelativeFilePath }, new[] { "$DTOCsprojPath$", csprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$EntitiesSlnFilePath$", slnRelativeFilePath }, new[] { "$EntitiesCsprojPath$", csprojPath }, new[] { "$EntitiesFolderPath$", "." });
                    }

                    string serverTT = Path.Combine(waqsDirectory, edmxName + ".Server.tt");
                    if (!File.Exists(serverTT))
                    {
                        CopyTTFile(Path.Combine(toolsServerPath, "Server.tt"), serverTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath   = Path.Combine(Path.GetDirectoryName(toolsServerPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                        {
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        }
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            bool addGlobalService = false;
            try
            {
                int argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                {
                    edmxPath = null;
                    edmxName = null;
                }
                else
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                string edmxProjectPath = args[argIndex++];
                string projectDirectoryPath = args[argIndex++];
                string toolsServerPath = args[argIndex++];
                string rootNamespace = args[argIndex++];
                string assemblyName = args[argIndex++];
                string assemblyVersion = args[argIndex++];
                string netVersion = args[argIndex++];
                string vsVersion = args[argIndex++];
                string kind = args[argIndex++];
                string appKind = args[argIndex++];
                string waqsDirectory = args[argIndex++];
                string appConfigPath = args[argIndex++];
                bool sourceControl = args[argIndex++] == "WithSourceControl";
                string slnFilePath = args[argIndex++];
                bool isWCF = args[argIndex++] == "WCF";
                string slnTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerTemplates");

                string dalInterfacesNamespace = null;
                string dalNamespace = null;
                string serviceInterfacesNamespace = null;
                string serviceNamespace = null;
                string wcfServiceContractNamespace = null;
                string wcfServiceNamespace = null;
                string csprojPath = null;
                string specificationsFolderPath = null;
                string dtoFolderPath = null;

                string assemblyNetVersion = null;
                switch (netVersion)
                {
                    case "NET40":
                        assemblyVersion = "4.0";
                        break;
                    case "NET45":
                        assemblyNetVersion = "4.5";
                        break;
                    case "NET46":
                        assemblyNetVersion = "4.6";
                        break;
                    default:
                        throw new NotImplementedException();
                }

                if (kind == "GlobalOnly")
                {
                    string dalInterfaces;
                    using (StreamReader sr = new StreamReader(args[argIndex++]))
                    {
                        dalInterfaces = sr.ReadToEnd();
                    }
                    dalInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dalInterfaces));
                    string dalFileName = args[argIndex++];
                    if (!string.IsNullOrEmpty(dalFileName))
                    {
                        string dal;
                        using (StreamReader sr = new StreamReader(dalFileName))
                        {
                            dal = sr.ReadToEnd();
                        }
                        dalNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dal));
                    }
                    string serviceInterfacesFileName = args[argIndex++];
                    if (!string.IsNullOrEmpty(serviceInterfacesFileName))
                    {
                        string serviceInterfaces;
                        using (StreamReader sr = new StreamReader(serviceInterfacesFileName))
                        {
                            serviceInterfaces = sr.ReadToEnd();
                        }
                        serviceInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(serviceInterfaces));
                    }
                    string serviceFileName = args[argIndex++];
                    if (!string.IsNullOrEmpty(serviceFileName))
                    {
                        string service;
                        using (StreamReader sr = new StreamReader(serviceFileName))
                        {
                            service = sr.ReadToEnd();
                        }
                        serviceNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(service));
                    }
                    if (isWCF)
                    {
                        string wcfServiceContractFileName = args[argIndex++];
                        if (!string.IsNullOrEmpty(wcfServiceContractFileName))
                        {
                            string wcfServiceContract;
                            using (StreamReader sr = new StreamReader(wcfServiceContractFileName))
                            {
                                wcfServiceContract = sr.ReadToEnd();
                            }
                            wcfServiceContractNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(wcfServiceContract));
                        }
                        string wcfServiceFileName = args[argIndex++];
                        if (!string.IsNullOrEmpty(wcfServiceFileName))
                        {
                            string wcfService;
                            using (StreamReader sr = new StreamReader(wcfServiceFileName))
                            {
                                wcfService = sr.ReadToEnd();
                            }
                            wcfServiceNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(wcfService));
                        }
                        string globalDirectoryPath = Path.Combine(projectDirectoryPath, "Global");
                        if (Directory.Exists(globalDirectoryPath))
                        {
                            string globalWCFServicePath = Path.Combine(globalDirectoryPath, "GlobalWCFService.cs");
                            if (File.Exists(globalWCFServicePath))
                            {
                                string globalWCFServiceContent;
                                using (var sr = new StreamReader(globalWCFServicePath))
                                {
                                    globalWCFServiceContent = sr.ReadToEnd();
                                }
                                using (var sw = new StreamWriter(globalWCFServicePath))
                                {
                                    sw.WriteLine(new GlobalWCFServiceRewriter(edmxName).Visit(SyntaxFactory.ParseCompilationUnit(globalWCFServiceContent)).NormalizeWhitespace().ToString());
                                }
                            }
                        }
                        else
                        {
                            addGlobalService = true;
                            Directory.CreateDirectory(globalDirectoryPath);
                            using (var sw = new StreamWriter(Path.Combine(globalDirectoryPath, "GlobalWCFService.cs")))
                            {
                                sw.WriteLine(string.Concat(
            @"using System.Transactions;

            namespace ", rootNamespace, @"
            {
            public partial class GlobalWCFService : IGlobalWCFService
            {
            public GlobalSerializedContexts SaveChanges(GlobalSerializedContexts clientContexts)
            {
                using (var transaction = new TransactionScope())
                {
                    ", edmxName, @"SaveChanges(clientContexts);
                    transaction.Complete();
                    return clientContexts;
                }
            }
            }
            }"));
                            }
                            string globalTTFilePath = Path.Combine(globalDirectoryPath, "GlobalWCFServiceContract.tt");
                            if (!File.Exists(globalTTFilePath))
                                CopyTTFile(Path.Combine(toolsServerPath, "Server.Global.tt"), globalTTFilePath, sourceControl, slnTTIncludesPath, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });

                            using (var sw = new StreamWriter(Path.Combine(projectDirectoryPath, "Global.svc")))
                            {
                                sw.WriteLine(string.Concat("<%@ ServiceHost Language=\"C#\" Service=\"", rootNamespace, ".GlobalWCFService\" %>"));
                            }
                        }
                    }
                }

                if (kind != "FrameworkOnly")
                {
                    csprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoFolderPath = args[argIndex++];
                    if (kind != "GlobalOnly")
                    {
                        Directory.CreateDirectory(specificationsFolderPath);
                        Directory.CreateDirectory(dtoFolderPath);
                    }
                }

                if (kind == "All" || kind == "WithoutFramework" || kind == "GlobalOnly")
                {
                    if (appKind == "App")
                        WriteAppGlobal(edmxPath, edmxName, edmxProjectPath, projectDirectoryPath, toolsServerPath, rootNamespace, assemblyName, assemblyVersion, appConfigPath, addGlobalService);
                    else
                        WriteWebGlobal(edmxPath, edmxName, edmxProjectPath, projectDirectoryPath, toolsServerPath, rootNamespace, assemblyNetVersion, assemblyName, assemblyVersion, wcfServiceNamespace, appConfigPath, addGlobalService, isWCF);
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    Directory.CreateDirectory(waqsDirectory);

                    string waqsToolsPath = null;
                    switch (kind)
                    {
                        case "All":
                            waqsToolsPath = Path.Combine(toolsServerPath, "Server.waqs");
                            break;
                        case "WithoutGlobal":
                            waqsToolsPath = Path.Combine(toolsServerPath, "ServerWithoutGlobal.waqs");
                            break;
                        case "WithoutFramework":
                            waqsToolsPath = Path.Combine(toolsServerPath, "ServerWithoutFramework.waqs");
                            break;
                        case "WithoutGlobalWithoutFramework":
                            waqsToolsPath = Path.Combine(toolsServerPath, "ServerWithoutGlobalWithoutFramework.waqs");
                            break;
                        case "FrameworkOnly":
                            waqsToolsPath = Path.Combine(toolsServerPath, "ServerFrameworkOnly.waqs");
                            edmxName = "Framework";
                            break;
                        case "GlobalOnly":
                            waqsToolsPath = Path.Combine(toolsServerPath, "ServerGlobalOnly.waqs");
                            break;
                    }
                    string serverWAQS = Path.Combine(waqsDirectory, edmxName + ".Server.waqs");
                    if (!File.Exists(serverWAQS))
                    {
                        csprojPath = GetRelativePath(csprojPath, waqsDirectory);
                        var slnRelativeFilePath = GetRelativePath(slnFilePath, waqsDirectory);
                        specificationsFolderPath = GetRelativePath(specificationsFolderPath, waqsDirectory);
                        dtoFolderPath = GetRelativePath(dtoFolderPath, waqsDirectory);
                        CopyFile(waqsToolsPath, serverWAQS, new[] { "$edmxPath$", edmxPath == null ? null : edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$DALInterfacesNamespace$", dalInterfacesNamespace }, new[] { "$DALNamespace$", dalNamespace }, new[] { "$ServiceInterfacesNamespace$", serviceInterfacesNamespace }, new[] { "$ServiceNamespace$", serviceNamespace }, new[] { "$WCFServiceContractNamespace$", wcfServiceContractNamespace }, new[] { "$WCFServiceNamespace$", wcfServiceNamespace }, new[] { "$SpecificationsSlnFilePath$", slnRelativeFilePath }, new[] { "$SpecificationsCsprojPath$", csprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", slnRelativeFilePath }, new[] { "$DTOCsprojPath$", csprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$EntitiesSlnFilePath$", slnRelativeFilePath }, new[] { "$EntitiesCsprojPath$", csprojPath }, new[] { "$EntitiesFolderPath$", "." });
                    }

                    string serverTT = Path.Combine(waqsDirectory, edmxName + ".Server.tt");
                    if (!File.Exists(serverTT))
                        CopyTTFile(Path.Combine(toolsServerPath, "Server.tt"), serverTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath = Path.Combine(Path.GetDirectoryName(toolsServerPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            try
            {
                int argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                    edmxName = null;
                else
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                string projectDirectoryPath = args[argIndex++];
                string toolsServerMockPath = args[argIndex++];
                string rootNamespace = args[argIndex++];
                string waqsDirectory = args[argIndex++];
                string waqsGeneralDirectory = args[argIndex++];
                string entitiesSolutionPath = args[argIndex++];
                string entitiesProjectPath = args[argIndex++];
                string netVersion = args[argIndex++];
                string vsVersion = args[argIndex++];
                string kind = args[argIndex++];
                bool sourceControl = args[argIndex++] == "WithSourceControl";
                string slnFilePath = args[argIndex++];
                string slnTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerMockTemplates");
                string entitiesFolderPath = null;
                string specificationsSlnFilePath = slnFilePath;
                string specificationsCsprojPath = null;
                string specificationsFolderPath = null;
                string serverEntitiesNamespace = null;
                string serverDALInterfacesNamespace = null;
                string serverDALNamespace = null;
                string dtoCsprojPath = null;
                string dtoFolderPath = null;
                string edmxProjectPath = null;
                string appConfigPath = null;

                if (kind == "All" || kind == "WithoutFramework")
                {
                    specificationsCsprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoCsprojPath = args[argIndex++];
                    dtoFolderPath = args[argIndex++];
                    entitiesFolderPath = Path.GetDirectoryName(args[argIndex]);
                    string entityContent;
                    using (var sr = new StreamReader(args[argIndex++]))
                    {
                        entityContent = sr.ReadToEnd();
                    }
                    serverEntitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entityContent));
                    string dalInterfacesContent;
                    using (var sr = new StreamReader(args[argIndex++]))
                    {
                        dalInterfacesContent = sr.ReadToEnd();
                    }
                    serverDALInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dalInterfacesContent));
                    string dalContent;
                    using (var sr = new StreamReader(args[argIndex++]))
                    {
                        dalContent = sr.ReadToEnd();
                    }
                    serverDALNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dalContent));
                    edmxProjectPath = args[argIndex++];
                    appConfigPath = args[argIndex++];
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    string entitiesNamespace = null;
                    string clientContextNamespace = null;

                    Directory.CreateDirectory(waqsDirectory);

                    string toolsWaqsPath = null;
                    switch (kind)
                    {
                        case "All":
                            toolsWaqsPath = Path.Combine(toolsServerMockPath, "Server.Mock.waqs");
                            break;
                        case "WithoutFramework":
                            toolsWaqsPath = Path.Combine(toolsServerMockPath, "Server.MockWithoutFramework.waqs");
                            break;
                        case "FrameworkOnly":
                            toolsWaqsPath = Path.Combine(toolsServerMockPath, "Server.MockFrameworkOnly.waqs");
                            edmxName = "Framework";
                            break;
                    }
                    string serverMockWAQS = Path.Combine(waqsDirectory, edmxName + ".Server.Mock.waqs");
                    if (toolsWaqsPath != null)
                    {
                        if (!File.Exists(serverMockWAQS))
                        {
                            entitiesSolutionPath = GetRelativePath(entitiesSolutionPath, waqsDirectory);
                            entitiesProjectPath = GetRelativePath(entitiesProjectPath, waqsDirectory);
                            specificationsSlnFilePath = GetRelativePath(specificationsSlnFilePath, waqsDirectory);
                            specificationsCsprojPath = GetRelativePath(specificationsCsprojPath, waqsDirectory);
                            specificationsFolderPath = GetRelativePath(specificationsFolderPath, waqsDirectory);
                            dtoCsprojPath = GetRelativePath(dtoCsprojPath, waqsDirectory);
                            dtoFolderPath = GetRelativePath(dtoFolderPath, waqsDirectory);
                            entitiesFolderPath = GetRelativePath(entitiesFolderPath, waqsDirectory);
                            CopyFile(toolsWaqsPath, serverMockWAQS, new[] { "$edmxPath$", edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$ServerEntitiesSolutionPath$", entitiesSolutionPath }, new[] { "$ServerEntitiesProjectPath$", entitiesProjectPath }, new[] { "$ServerDALInterfacesNamespace$", serverDALInterfacesNamespace }, new[] { "$ServerDALNamespace$", serverDALNamespace }, new[] { "$EntitiesNamespace$", entitiesNamespace }, new[] { "$ClientContextNamespace$", clientContextNamespace }, new[] { "$SpecificationsSlnFilePath$", specificationsSlnFilePath }, new[] { "$SpecificationsCsprojPath$", specificationsCsprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", specificationsSlnFilePath }, new[] { "$DTOCsprojPath$", dtoCsprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$ServerEntitiesSolutionPath$", specificationsSlnFilePath }, new[] { "$ServerEntitiesProjectPath$", specificationsCsprojPath }, new[] { "$ServerEntitiesFolderPath$", entitiesFolderPath + "\\" }, new[] { "$ServerEntitiesNamespace$", serverEntitiesNamespace });
                        }

                        string serverMockTT = Path.Combine(waqsDirectory, edmxName + ".Server.Mock.tt");
                        if (!File.Exists(serverMockTT))
                            CopyTTFile(Path.Combine(toolsServerMockPath, "Server.Mock.tt"), serverMockTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                    }

                    if (kind != "FrameworkOnly")
                    {
                        string appConfigFilePath = Path.Combine(projectDirectoryPath, "App.config");

                        if (!File.Exists(appConfigFilePath))
                            CopyFile(Path.Combine(toolsServerMockPath, "App.config"), appConfigFilePath);

                        XElement appConfig = XElement.Load(appConfigFilePath);
                        XElement connectionStrings = appConfig.Element("connectionStrings");
                        string edmxFolderPath = Path.GetDirectoryName(edmxPath);
                        string edmxProjectFolderPath = Path.GetDirectoryName(edmxProjectPath);
                        string folderDiff = edmxFolderPath.Substring(edmxProjectFolderPath.Length + (edmxFolderPath.Length > edmxProjectFolderPath.Length ? 1 : 0));
                        if (connectionStrings == null)
                        {
                            if (appConfigPath != null)
                            {
                                XElement templateConfig = XElement.Load(appConfigPath);
                                XElement appConnectionString = templateConfig.Element("connectionStrings").Elements("add").FirstOrDefault(add => add.Attribute("connectionString").Value.Contains(edmxName + ".csdl"));
                                appConnectionString.Attribute("connectionString").Value = Regex.Replace(appConnectionString.Attribute("connectionString").Value, string.Concat(@"(?:[^\|\/]+\.)?", edmxName, "(.(?:csdl|ssdl|msl))"), m => string.Concat("WAQS.", edmxName, ".", edmxName, m.Groups[1].Value));
                                appConfig.Add(
                                    new XElement("connectionStrings", appConnectionString));
                            }
                        }
                        else
                        {
                            XElement connectionString = connectionStrings.Elements("add").FirstOrDefault(add => add.Attribute("connectionString").Value.Contains(edmxName + ".csdl"));
                            if (connectionString == null)
                            {
                                if (appConfigPath != null)
                                {
                                    XElement templateConfig = XElement.Load(appConfigPath);
                                    XElement appConnectionString = templateConfig.Element("connectionStrings").Elements("add").FirstOrDefault(add => add.Attribute("connectionString").Value.Contains(edmxName + ".csdl"));
                                    appConnectionString.Attribute("connectionString").Value = Regex.Replace(appConnectionString.Attribute("connectionString").Value, string.Concat(@"(?:[^\|\/]+\.)?", edmxName, "(.(?:csdl|ssdl|msl))"), m => string.Concat("WAQS.", edmxName, ".", edmxName, m.Groups[1].Value));
                                    connectionStrings.Add(appConnectionString);
                                }
                            }
                            else
                                connectionString.Attribute("connectionString").Value = Regex.Replace(connectionString.Attribute("connectionString").Value, string.Concat(@"(?:[^\|\/]+\.)?", edmxName, "(.(?:csdl|ssdl|msl))"), m => string.Concat("WAQS.", edmxName, ".", edmxName, m.Groups[1].Value));
                        }

                        appConfig.Save(appConfigFilePath);
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath = Path.Combine(Path.GetDirectoryName(toolsServerMockPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerMockTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            try
            {
                int    argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                {
                    edmxName = null;
                }
                else
                {
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                }
                string projectDirectoryPath = args[argIndex++];
                string toolsServerMockPath  = args[argIndex++];
                string rootNamespace        = args[argIndex++];
                string waqsDirectory        = args[argIndex++];
                string waqsGeneralDirectory = args[argIndex++];
                string entitiesSolutionPath = args[argIndex++];
                string entitiesProjectPath  = args[argIndex++];
                string netVersion           = args[argIndex++];
                string vsVersion            = args[argIndex++];
                string kind                         = args[argIndex++];
                bool   sourceControl                = args[argIndex++] == "WithSourceControl";
                string slnFilePath                  = args[argIndex++];
                string slnTTIncludesPath            = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerMockTemplates");
                string entitiesFolderPath           = null;
                string specificationsSlnFilePath    = slnFilePath;
                string specificationsCsprojPath     = null;
                string specificationsFolderPath     = null;
                string serverEntitiesNamespace      = null;
                string serverDALInterfacesNamespace = null;
                string serverDALNamespace           = null;
                string dtoCsprojPath                = null;
                string dtoFolderPath                = null;
                string edmxProjectPath              = null;
                string appConfigPath                = null;

                if (kind == "All" || kind == "WithoutFramework")
                {
                    specificationsCsprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoCsprojPath            = args[argIndex++];
                    dtoFolderPath            = args[argIndex++];
                    entitiesFolderPath       = Path.GetDirectoryName(args[argIndex]);
                    string entityContent;
                    using (var sr = new StreamReader(args[argIndex++]))
                    {
                        entityContent = sr.ReadToEnd();
                    }
                    serverEntitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entityContent));
                    string dalInterfacesContent;
                    using (var sr = new StreamReader(args[argIndex++]))
                    {
                        dalInterfacesContent = sr.ReadToEnd();
                    }
                    serverDALInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dalInterfacesContent));
                    string dalContent;
                    using (var sr = new StreamReader(args[argIndex++]))
                    {
                        dalContent = sr.ReadToEnd();
                    }
                    serverDALNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(dalContent));
                    edmxProjectPath    = args[argIndex++];
                    appConfigPath      = args[argIndex++];
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    string entitiesNamespace      = null;
                    string clientContextNamespace = null;

                    Directory.CreateDirectory(waqsDirectory);

                    string toolsWaqsPath = null;
                    switch (kind)
                    {
                    case "All":
                        toolsWaqsPath = Path.Combine(toolsServerMockPath, "Server.Mock.waqs");
                        break;

                    case "WithoutFramework":
                        toolsWaqsPath = Path.Combine(toolsServerMockPath, "Server.MockWithoutFramework.waqs");
                        break;

                    case "FrameworkOnly":
                        toolsWaqsPath = Path.Combine(toolsServerMockPath, "Server.MockFrameworkOnly.waqs");
                        edmxName      = "Framework";
                        break;
                    }
                    string serverMockWAQS = Path.Combine(waqsDirectory, edmxName + ".Server.Mock.waqs");
                    if (toolsWaqsPath != null)
                    {
                        if (!File.Exists(serverMockWAQS))
                        {
                            entitiesSolutionPath      = GetRelativePath(entitiesSolutionPath, waqsDirectory);
                            entitiesProjectPath       = GetRelativePath(entitiesProjectPath, waqsDirectory);
                            specificationsSlnFilePath = GetRelativePath(specificationsSlnFilePath, waqsDirectory);
                            specificationsCsprojPath  = GetRelativePath(specificationsCsprojPath, waqsDirectory);
                            specificationsFolderPath  = GetRelativePath(specificationsFolderPath, waqsDirectory);
                            dtoCsprojPath             = GetRelativePath(dtoCsprojPath, waqsDirectory);
                            dtoFolderPath             = GetRelativePath(dtoFolderPath, waqsDirectory);
                            entitiesFolderPath        = GetRelativePath(entitiesFolderPath, waqsDirectory);
                            CopyFile(toolsWaqsPath, serverMockWAQS, new[] { "$edmxPath$", edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$ServerEntitiesSolutionPath$", entitiesSolutionPath }, new[] { "$ServerEntitiesProjectPath$", entitiesProjectPath }, new[] { "$ServerDALInterfacesNamespace$", serverDALInterfacesNamespace }, new[] { "$ServerDALNamespace$", serverDALNamespace }, new[] { "$EntitiesNamespace$", entitiesNamespace }, new[] { "$ClientContextNamespace$", clientContextNamespace }, new[] { "$SpecificationsSlnFilePath$", specificationsSlnFilePath }, new[] { "$SpecificationsCsprojPath$", specificationsCsprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", specificationsSlnFilePath }, new[] { "$DTOCsprojPath$", dtoCsprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$ServerEntitiesSolutionPath$", specificationsSlnFilePath }, new[] { "$ServerEntitiesProjectPath$", specificationsCsprojPath }, new[] { "$ServerEntitiesFolderPath$", entitiesFolderPath + "\\" }, new[] { "$ServerEntitiesNamespace$", serverEntitiesNamespace });
                        }

                        string serverMockTT = Path.Combine(waqsDirectory, edmxName + ".Server.Mock.tt");
                        if (!File.Exists(serverMockTT))
                        {
                            CopyTTFile(Path.Combine(toolsServerMockPath, "Server.Mock.tt"), serverMockTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                        }
                    }

                    if (kind != "FrameworkOnly")
                    {
                        string appConfigFilePath = Path.Combine(projectDirectoryPath, "App.config");

                        if (!File.Exists(appConfigFilePath))
                        {
                            CopyFile(Path.Combine(toolsServerMockPath, "App.config"), appConfigFilePath);
                        }

                        XElement appConfig             = XElement.Load(appConfigFilePath);
                        XElement connectionStrings     = appConfig.Element("connectionStrings");
                        string   edmxFolderPath        = Path.GetDirectoryName(edmxPath);
                        string   edmxProjectFolderPath = Path.GetDirectoryName(edmxProjectPath);
                        string   folderDiff            = edmxFolderPath.Substring(edmxProjectFolderPath.Length + (edmxFolderPath.Length > edmxProjectFolderPath.Length ? 1 : 0));
                        if (connectionStrings == null)
                        {
                            if (appConfigPath != null)
                            {
                                XElement templateConfig      = XElement.Load(appConfigPath);
                                XElement appConnectionString = templateConfig.Element("connectionStrings").Elements("add").FirstOrDefault(add => add.Attribute("connectionString").Value.Contains(edmxName + ".csdl"));
                                appConnectionString.Attribute("connectionString").Value = Regex.Replace(appConnectionString.Attribute("connectionString").Value, string.Concat(@"(?:[^\|\/]+\.)?", edmxName, "(.(?:csdl|ssdl|msl))"), m => string.Concat("WAQS.", edmxName, ".", edmxName, m.Groups[1].Value));
                                appConfig.Add(
                                    new XElement("connectionStrings", appConnectionString));
                            }
                        }
                        else
                        {
                            XElement connectionString = connectionStrings.Elements("add").FirstOrDefault(add => add.Attribute("connectionString").Value.Contains(edmxName + ".csdl"));
                            if (connectionString == null)
                            {
                                if (appConfigPath != null)
                                {
                                    XElement templateConfig      = XElement.Load(appConfigPath);
                                    XElement appConnectionString = templateConfig.Element("connectionStrings").Elements("add").FirstOrDefault(add => add.Attribute("connectionString").Value.Contains(edmxName + ".csdl"));
                                    appConnectionString.Attribute("connectionString").Value = Regex.Replace(appConnectionString.Attribute("connectionString").Value, string.Concat(@"(?:[^\|\/]+\.)?", edmxName, "(.(?:csdl|ssdl|msl))"), m => string.Concat("WAQS.", edmxName, ".", edmxName, m.Groups[1].Value));
                                    connectionStrings.Add(appConnectionString);
                                }
                            }
                            else
                            {
                                connectionString.Attribute("connectionString").Value = Regex.Replace(connectionString.Attribute("connectionString").Value, string.Concat(@"(?:[^\|\/]+\.)?", edmxName, "(.(?:csdl|ssdl|msl))"), m => string.Concat("WAQS.", edmxName, ".", edmxName, m.Groups[1].Value));
                            }
                        }

                        appConfig.Save(appConfigFilePath);
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath   = Path.Combine(Path.GetDirectoryName(toolsServerMockPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "ServerMockTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                        {
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        }
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            try
            {
                int    argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                {
                    edmxName = null;
                }
                else
                {
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                }
                string toolsClientPCLPath          = args[argIndex++];
                string rootNamespace               = args[argIndex++];
                string svcUrl                      = args[argIndex++];
                string waqsDirectory               = args[argIndex++];
                string waqsGeneralDirectory        = args[argIndex++];
                string expressionTransformerPath   = args[argIndex++];
                string serviceContractPath         = args[argIndex++];
                string entitiesPath                = args[argIndex++];
                string clientContextPath           = args[argIndex++];
                string clientContextInterfacesPath = args[argIndex++];
                string serverEntitiesSolutionPath  = args[argIndex++];
                string serverEntitiesProjectPath   = args[argIndex++];
                string netVersion                  = args[argIndex++];
                string vsVersion                   = args[argIndex++];
                string kind                      = args[argIndex++];
                bool   sourceControl             = args[argIndex++] == "WithSourceControl";
                string slnFilePath               = args[argIndex++];
                string slnTTIncludesPath         = Path.Combine(Path.GetDirectoryName(slnFilePath), "PCLClientTemplates");
                string serverEntitiesFolderPath  = null;
                string specificationsSlnFilePath = slnFilePath;
                string specificationsCsprojPath  = null;
                string specificationsFolderPath  = null;
                string dtoSlnFilePath            = null;
                string dtoCsprojPath             = null;
                string dtoFolderPath             = null;
                string serverEntitiesNamespace   = null;

                if (kind == "All" || kind == "WithoutFramework" || kind == "WithoutGlobal" || kind == "WithoutGlobalWithoutFramework")
                {
                    dtoSlnFilePath           = specificationsSlnFilePath;
                    specificationsCsprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoCsprojPath            = args[argIndex++];
                    dtoFolderPath            = args[argIndex++];
                    var edmxDirectoryPath = Path.GetDirectoryName(edmxPath);
                    if (edmxDirectoryPath == Path.GetDirectoryName(serverEntitiesProjectPath))
                    {
                        if (Directory.Exists(specificationsFolderPath = Path.Combine(edmxDirectoryPath, "Specifications")))
                        {
                            specificationsCsprojPath = serverEntitiesProjectPath;
                        }
                        if (Directory.Exists(dtoFolderPath = Path.Combine(edmxDirectoryPath, "DTO")))
                        {
                            dtoCsprojPath = serverEntitiesProjectPath;
                        }
                    }
                    serverEntitiesFolderPath = Path.GetDirectoryName(args[argIndex]);
                    string entityContent;
                    using (var sr = new StreamReader(args[argIndex]))
                    {
                        entityContent = sr.ReadToEnd();
                    }
                    serverEntitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entityContent));
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    string entitiesNamespace                = null;
                    string clientContextNamespace           = null;
                    string clientContextInterfacesNamespace = null;
                    if (kind == "GlobalOnly" && !(string.IsNullOrEmpty(expressionTransformerPath) || string.IsNullOrEmpty(serviceContractPath) || string.IsNullOrEmpty(entitiesPath) || string.IsNullOrEmpty(clientContextPath) || string.IsNullOrEmpty(clientContextInterfacesPath)))
                    {
                        string expressionTransformerContent;
                        using (var sr = new StreamReader(expressionTransformerPath))
                        {
                            expressionTransformerContent = sr.ReadToEnd();
                        }
                        string serviceContractContent;
                        using (var sr = new StreamReader(serviceContractPath))
                        {
                            serviceContractContent = sr.ReadToEnd();
                        }
                        new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(serviceContractContent));
                        string entitiesContent;
                        using (var sr = new StreamReader(entitiesPath))
                        {
                            entitiesContent = sr.ReadToEnd();
                        }
                        entitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entitiesContent));
                        string clientContextContent;
                        using (var sr = new StreamReader(clientContextPath))
                        {
                            clientContextContent = sr.ReadToEnd();
                        }
                        clientContextNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextContent));
                        string clientContextInterfacesContent;
                        using (var sr = new StreamReader(clientContextInterfacesPath))
                        {
                            clientContextInterfacesContent = sr.ReadToEnd();
                        }
                        clientContextInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextInterfacesContent));
                    }
                    if (kind == "GlobalOnly")
                    {
                        string contextsFilePath = Path.Combine(waqsGeneralDirectory, "Contexts.xml");
                        if (Directory.Exists(waqsGeneralDirectory))
                        {
                            if (File.Exists(contextsFilePath))
                            {
                                var contexts = XElement.Load(contextsFilePath);
                                contexts.Add(XElement.Parse(string.Format("<Context Name=\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.PCL.waqs\" />", edmxName)));
                                contexts.Save(contextsFilePath);
                            }
                        }
                        else
                        {
                            Directory.CreateDirectory(waqsGeneralDirectory);
                            if (kind == "GlobalOnly")
                            {
                                using (var sw = new StreamWriter(contextsFilePath))
                                {
                                    sw.WriteLine(string.Concat(
                                                     @"<Contexts>
    <Context Name=", "\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.PCL.waqs\" />", @"
</Contexts>"), edmxName);
                                }
                            }
                        }
                    }

                    Directory.CreateDirectory(waqsDirectory);

                    string toolsWaqsPath = null;
                    switch (kind)
                    {
                    case "All":
                    case "WithoutGlobal":
                        toolsWaqsPath = Path.Combine(toolsClientPCLPath, "Client.PCL.waqs");
                        break;

                    case "WithoutFramework":
                    case "WithoutGlobalWithoutFramework":
                        toolsWaqsPath = Path.Combine(toolsClientPCLPath, "ClientWithoutFramework.PCL.waqs");
                        break;

                    case "FrameworkOnly":
                        toolsWaqsPath = Path.Combine(toolsClientPCLPath, "ClientFrameworkOnly.PCL.waqs");
                        edmxName      = "Framework";
                        break;

                    case "GlobalOnly":
                        toolsWaqsPath = Path.Combine(toolsClientPCLPath, "ClientGlobalOnly.PCL.waqs");
                        break;
                    }
                    string clientPCLWAQS = Path.Combine(waqsDirectory, edmxName + ".Client.PCL.waqs");
                    if (toolsWaqsPath != null)
                    {
                        if (!File.Exists(clientPCLWAQS))
                        {
                            serverEntitiesSolutionPath = GetRelativePath(serverEntitiesSolutionPath, waqsDirectory);
                            serverEntitiesProjectPath  = GetRelativePath(serverEntitiesProjectPath, waqsDirectory);
                            specificationsSlnFilePath  = GetRelativePath(specificationsSlnFilePath, waqsDirectory);
                            specificationsCsprojPath   = GetRelativePath(specificationsCsprojPath, waqsDirectory);
                            specificationsFolderPath   = GetRelativePath(specificationsFolderPath, waqsDirectory);
                            serverEntitiesFolderPath   = GetRelativePath(serverEntitiesFolderPath, waqsDirectory);
                            dtoSlnFilePath             = GetRelativePath(dtoSlnFilePath, waqsDirectory);
                            dtoCsprojPath = GetRelativePath(dtoCsprojPath, waqsDirectory);
                            dtoFolderPath = GetRelativePath(dtoFolderPath, waqsDirectory);
                            CopyFile(toolsWaqsPath, clientPCLWAQS, new[] { "$edmxPath$", edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$svcUrl$", svcUrl }, new[] { "$EntitiesNamespace$", entitiesNamespace }, new[] { "$ClientContextNamespace$", clientContextNamespace }, new[] { "$ClientContextInterfacesNamespace$", clientContextInterfacesNamespace }, new[] { "$SpecificationsSlnFilePath$", specificationsSlnFilePath }, new[] { "$SpecificationsCsprojPath$", specificationsCsprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", dtoSlnFilePath }, new[] { "$DTOCsprojPath$", dtoCsprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$ServerEntitiesSlnFilePath$", serverEntitiesSolutionPath }, new[] { "$ServerEntitiesCsprojPath$", serverEntitiesProjectPath }, new[] { "$ServerEntitiesFolderPath$", serverEntitiesFolderPath + "\\" }, new[] { "$ServerEntitiesNamespace$", serverEntitiesNamespace });
                        }

                        if (kind != "GlobalOnly")
                        {
                            string clientPCLTT = Path.Combine(waqsDirectory, edmxName + ".Client.PCL.tt");
                            if (!File.Exists(clientPCLTT))
                            {
                                CopyTTFile(Path.Combine(toolsClientPCLPath, "Client.PCL.tt"), clientPCLTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                            }
                        }
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath   = Path.Combine(Path.GetDirectoryName(toolsClientPCLPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "PCLClientTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                        {
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        }
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            try
            {
                int argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                    edmxName = null;
                else
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                string toolsClientPCLPath = args[argIndex++];
                string rootNamespace = args[argIndex++];
                string svcUrl = args[argIndex++];
                string waqsDirectory = args[argIndex++];
                string waqsGeneralDirectory = args[argIndex++];
                string expressionTransformerPath = args[argIndex++];
                string serviceContractPath = args[argIndex++];
                string entitiesPath = args[argIndex++];
                string clientContextPath = args[argIndex++];
                string clientContextInterfacesPath = args[argIndex++];
                string serverEntitiesSolutionPath = args[argIndex++];
                string serverEntitiesProjectPath = args[argIndex++];
                string netVersion = args[argIndex++];
                string vsVersion = args[argIndex++];
                string kind = args[argIndex++];
                bool sourceControl = args[argIndex++] == "WithSourceControl";
                string slnFilePath = args[argIndex++];
                string slnTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "PCLClientTemplates");
                string serverEntitiesFolderPath = null;
                string specificationsSlnFilePath = slnFilePath;
                string specificationsCsprojPath = null;
                string specificationsFolderPath = null;
                string dtoSlnFilePath = null;
                string dtoCsprojPath = null;
                string dtoFolderPath = null;
                string serverEntitiesNamespace = null;

                if (kind == "All" || kind == "WithoutFramework" || kind == "WithoutGlobal" || kind == "WithoutGlobalWithoutFramework")
                {
                    dtoSlnFilePath = specificationsSlnFilePath;
                    specificationsCsprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoCsprojPath = args[argIndex++];
                    dtoFolderPath = args[argIndex++];
                    var edmxDirectoryPath = Path.GetDirectoryName(edmxPath);
                    if (edmxDirectoryPath == Path.GetDirectoryName(serverEntitiesProjectPath))
                    {
                        if (Directory.Exists(specificationsFolderPath = Path.Combine(edmxDirectoryPath, "Specifications")))
                            specificationsCsprojPath = serverEntitiesProjectPath;
                        if (Directory.Exists(dtoFolderPath = Path.Combine(edmxDirectoryPath, "DTO")))
                            dtoCsprojPath = serverEntitiesProjectPath;
                    }
                    serverEntitiesFolderPath = Path.GetDirectoryName(args[argIndex]);
                    string entityContent;
                    using (var sr = new StreamReader(args[argIndex]))
                    {
                        entityContent = sr.ReadToEnd();
                    }
                    serverEntitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entityContent));
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    string entitiesNamespace = null;
                    string clientContextNamespace = null;
                    string clientContextInterfacesNamespace = null;
                    if (kind == "GlobalOnly" && !(string.IsNullOrEmpty(expressionTransformerPath) || string.IsNullOrEmpty(serviceContractPath) || string.IsNullOrEmpty(entitiesPath) || string.IsNullOrEmpty(clientContextPath) || string.IsNullOrEmpty(clientContextInterfacesPath)))
                    {
                        string expressionTransformerContent;
                        using (var sr = new StreamReader(expressionTransformerPath))
                        {
                            expressionTransformerContent = sr.ReadToEnd();
                        }
                        string serviceContractContent;
                        using (var sr = new StreamReader(serviceContractPath))
                        {
                            serviceContractContent = sr.ReadToEnd();
                        }
                        new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(serviceContractContent));
                        string entitiesContent;
                        using (var sr = new StreamReader(entitiesPath))
                        {
                            entitiesContent = sr.ReadToEnd();
                        }
                        entitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entitiesContent));
                        string clientContextContent;
                        using (var sr = new StreamReader(clientContextPath))
                        {
                            clientContextContent = sr.ReadToEnd();
                        }
                        clientContextNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextContent));
                        string clientContextInterfacesContent;
                        using (var sr = new StreamReader(clientContextInterfacesPath))
                        {
                            clientContextInterfacesContent = sr.ReadToEnd();
                        }
                        clientContextInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextInterfacesContent));
                    }
                    if (kind == "GlobalOnly")
                    {
                        string contextsFilePath = Path.Combine(waqsGeneralDirectory, "Contexts.xml");
                        if (Directory.Exists(waqsGeneralDirectory))
                        {
                            if (File.Exists(contextsFilePath))
                            {
                                var contexts = XElement.Load(contextsFilePath);
                                contexts.Add(XElement.Parse(string.Format("<Context Name=\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.PCL.waqs\" />", edmxName)));
                                contexts.Save(contextsFilePath);
                            }
                        }
                        else
                        {
                            Directory.CreateDirectory(waqsGeneralDirectory);
                            if (kind == "GlobalOnly")
                                using (var sw = new StreamWriter(contextsFilePath))
                                {
                                    sw.WriteLine(string.Concat(
            @"<Contexts>
            <Context Name=", "\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.PCL.waqs\" />", @"
            </Contexts>"), edmxName);
                                }
                        }
                    }

                    Directory.CreateDirectory(waqsDirectory);

                    string toolsWaqsPath = null;
                    switch (kind)
                    {
                        case "All":
                        case "WithoutGlobal":
                            toolsWaqsPath = Path.Combine(toolsClientPCLPath, "Client.PCL.waqs");
                            break;
                        case "WithoutFramework":
                        case "WithoutGlobalWithoutFramework":
                            toolsWaqsPath = Path.Combine(toolsClientPCLPath, "ClientWithoutFramework.PCL.waqs");
                            break;
                        case "FrameworkOnly":
                            toolsWaqsPath = Path.Combine(toolsClientPCLPath, "ClientFrameworkOnly.PCL.waqs");
                            edmxName = "Framework";
                            break;
                        case "GlobalOnly":
                            toolsWaqsPath = Path.Combine(toolsClientPCLPath, "ClientGlobalOnly.PCL.waqs");
                            break;
                    }
                    string clientPCLWAQS = Path.Combine(waqsDirectory, edmxName + ".Client.PCL.waqs");
                    if (toolsWaqsPath != null)
                    {
                        if (!File.Exists(clientPCLWAQS))
                        {
                            serverEntitiesSolutionPath = GetRelativePath(serverEntitiesSolutionPath, waqsDirectory);
                            serverEntitiesProjectPath = GetRelativePath(serverEntitiesProjectPath, waqsDirectory);
                            specificationsSlnFilePath = GetRelativePath(specificationsSlnFilePath, waqsDirectory);
                            specificationsCsprojPath = GetRelativePath(specificationsCsprojPath, waqsDirectory);
                            specificationsFolderPath = GetRelativePath(specificationsFolderPath, waqsDirectory);
                            serverEntitiesFolderPath = GetRelativePath(serverEntitiesFolderPath, waqsDirectory);
                            dtoSlnFilePath = GetRelativePath(dtoSlnFilePath, waqsDirectory);
                            dtoCsprojPath = GetRelativePath(dtoCsprojPath, waqsDirectory);
                            dtoFolderPath = GetRelativePath(dtoFolderPath, waqsDirectory);
                            CopyFile(toolsWaqsPath, clientPCLWAQS, new[] { "$edmxPath$", edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$svcUrl$", svcUrl }, new[] { "$EntitiesNamespace$", entitiesNamespace }, new[] { "$ClientContextNamespace$", clientContextNamespace }, new[] { "$ClientContextInterfacesNamespace$", clientContextInterfacesNamespace }, new[] { "$SpecificationsSlnFilePath$", specificationsSlnFilePath }, new[] { "$SpecificationsCsprojPath$", specificationsCsprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", dtoSlnFilePath }, new[] { "$DTOCsprojPath$", dtoCsprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$ServerEntitiesSlnFilePath$", serverEntitiesSolutionPath }, new[] { "$ServerEntitiesCsprojPath$", serverEntitiesProjectPath }, new[] { "$ServerEntitiesFolderPath$", serverEntitiesFolderPath + "\\" }, new[] { "$ServerEntitiesNamespace$", serverEntitiesNamespace });
                        }

                        if (kind != "GlobalOnly")
                        {
                            string clientPCLTT = Path.Combine(waqsDirectory, edmxName + ".Client.PCL.tt");
                            if (!File.Exists(clientPCLTT))
                                CopyTTFile(Path.Combine(toolsClientPCLPath, "Client.PCL.tt"), clientPCLTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                        }
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath = Path.Combine(Path.GetDirectoryName(toolsClientPCLPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "PCLClientTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }

                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            try
            {
                int    argIndex = 0;
                string edmxPath = args[argIndex++];
                string edmxName;
                if (string.IsNullOrEmpty(edmxPath))
                {
                    edmxName = null;
                }
                else
                {
                    edmxName = Path.GetFileNameWithoutExtension(edmxPath);
                }
                string projectDirectoryPath = args[argIndex++];
                string toolsClientWPFPath   = args[argIndex++];
                string rootNamespace        = args[argIndex++];
                string svcUrl                      = args[argIndex++];
                string waqsDirectory               = args[argIndex++];
                string waqsGeneralDirectory        = args[argIndex++];
                string expressionTransformerPath   = args[argIndex++];
                string serviceContractPath         = args[argIndex++];
                string entitiesPath                = args[argIndex++];
                string clientContextPath           = args[argIndex++];
                string clientContextInterfacesPath = args[argIndex++];
                string serverEntitiesSolutionPath  = args[argIndex++];
                string serverEntitiesProjectPath   = args[argIndex++];
                string netVersion                  = args[argIndex++];
                string vsVersion                   = args[argIndex++];
                string kind                      = args[argIndex++];
                bool   sourceControl             = args[argIndex++] == "WithSourceControl";
                string slnFilePath               = args[argIndex++];
                string slnTTIncludesPath         = Path.Combine(Path.GetDirectoryName(slnFilePath), "WPFClientTemplates");
                string serverEntitiesFolderPath  = null;
                string specificationsSlnFilePath = slnFilePath;
                string specificationsCsprojPath  = null;
                string specificationsFolderPath  = null;
                string dtoSlnFilePath            = null;
                string dtoCsprojPath             = null;
                string dtoFolderPath             = null;
                string serverEntitiesNamespace   = null;

                if (kind == "All" || kind == "WithoutFramework" || kind == "WithoutGlobal" || kind == "WithoutGlobalWithoutFramework")
                {
                    dtoSlnFilePath           = specificationsSlnFilePath;
                    specificationsCsprojPath = args[argIndex++];
                    specificationsFolderPath = args[argIndex++];
                    dtoCsprojPath            = args[argIndex++];
                    dtoFolderPath            = args[argIndex++];
                    var edmxDirectoryPath = Path.GetDirectoryName(edmxPath);
                    if (edmxDirectoryPath == Path.GetDirectoryName(serverEntitiesProjectPath))
                    {
                        if (Directory.Exists(specificationsFolderPath = Path.Combine(edmxDirectoryPath, "Specifications")))
                        {
                            specificationsCsprojPath = serverEntitiesProjectPath;
                        }
                        if (Directory.Exists(dtoFolderPath = Path.Combine(edmxDirectoryPath, "DTO")))
                        {
                            dtoCsprojPath = serverEntitiesProjectPath;
                        }
                    }
                    serverEntitiesFolderPath = Path.GetDirectoryName(args[argIndex]);
                    string entityContent;
                    using (var sr = new StreamReader(args[argIndex]))
                    {
                        entityContent = sr.ReadToEnd();
                    }
                    serverEntitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entityContent));
                }

                if (!Directory.Exists(waqsDirectory))
                {
                    string serviceContractNamespace         = null;
                    string entitiesNamespace                = null;
                    string clientContextNamespace           = null;
                    string clientContextInterfacesNamespace = null;
                    if (kind == "GlobalOnly" && !(string.IsNullOrEmpty(expressionTransformerPath) || string.IsNullOrEmpty(serviceContractPath) || string.IsNullOrEmpty(entitiesPath) || string.IsNullOrEmpty(clientContextPath) || string.IsNullOrEmpty(clientContextInterfacesPath)))
                    {
                        string expressionTransformerContent;
                        using (var sr = new StreamReader(expressionTransformerPath))
                        {
                            expressionTransformerContent = sr.ReadToEnd();
                        }
                        string serviceContractContent;
                        using (var sr = new StreamReader(serviceContractPath))
                        {
                            serviceContractContent = sr.ReadToEnd();
                        }
                        serviceContractNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(serviceContractContent));
                        string entitiesContent;
                        using (var sr = new StreamReader(entitiesPath))
                        {
                            entitiesContent = sr.ReadToEnd();
                        }
                        entitiesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(entitiesContent));
                        string clientContextContent;
                        using (var sr = new StreamReader(clientContextPath))
                        {
                            clientContextContent = sr.ReadToEnd();
                        }
                        clientContextNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextContent));
                        string clientContextInterfacesContent;
                        using (var sr = new StreamReader(clientContextInterfacesPath))
                        {
                            clientContextInterfacesContent = sr.ReadToEnd();
                        }
                        clientContextInterfacesNamespace = new GetNamespace().Visit(SyntaxFactory.ParseCompilationUnit(clientContextInterfacesContent));
                    }

                    if (kind == "All" || kind == "WithoutFramework" || kind == "GlobalOnly")
                    {
                        if (kind == "GlobalOnly")
                        {
                            string contextsFilePath = Path.Combine(waqsGeneralDirectory, "Contexts.xml");
                            if (Directory.Exists(waqsGeneralDirectory))
                            {
                                if (File.Exists(contextsFilePath))
                                {
                                    var contexts = XElement.Load(contextsFilePath);
                                    contexts.Add(
                                        XElement.Parse(
                                            string.Format(
                                                "<Context Name=\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.WPF.waqs\" />",
                                                edmxName)));
                                    contexts.Save(contextsFilePath);
                                }
                            }
                            else
                            {
                                Directory.CreateDirectory(waqsGeneralDirectory);
                                using (var sw = new StreamWriter(contextsFilePath))
                                {
                                    sw.WriteLine(string.Concat(
                                                     @"<Contexts>
    <Context Name=", "\"{0}\" WAQS=\"..\\WAQS.{0}\\{0}.Client.WPF.waqs\" />", @"
</Contexts>"), edmxName);
                                }
                            }
                        }
                        string   appXamlFilePath   = Path.Combine(projectDirectoryPath, "App.xaml");
                        XElement appXaml           = XElement.Load(appXamlFilePath);
                        string   appXamlCsFilePath = Path.Combine(projectDirectoryPath, "App.xaml.cs");
                        if (appXaml != null)
                        {
                            string appXamlCsContent;
                            using (var sr = new StreamReader(appXamlCsFilePath))
                            {
                                appXamlCsContent = sr.ReadToEnd();
                            }
                            if (string.IsNullOrEmpty(clientContextNamespace))
                            {
                                clientContextNamespace = rootNamespace + ".ClientContext";
                            }
                            if (string.IsNullOrEmpty(clientContextInterfacesNamespace))
                            {
                                clientContextInterfacesNamespace = rootNamespace + ".ClientContext.Interfaces";
                            }
                            XAttribute startupUri = appXaml.Attribute("StartupUri");
                            if (startupUri != null)
                            {
                                string pageXamlFile = startupUri.Value;
                                string pageTypeName = XElement.Load(Path.Combine(projectDirectoryPath, pageXamlFile)).Attribute(XName.Get("Class", "http://schemas.microsoft.com/winfx/2006/xaml")).Value;
                                startupUri.Remove();
                                appXaml.Save(appXamlFilePath);

                                appXamlCsContent = new ApplicationStartupRewriter(edmxName, rootNamespace, clientContextNamespace, clientContextInterfacesNamespace, pageTypeName).Visit(SyntaxFactory.ParseCompilationUnit(appXamlCsContent)).NormalizeWhitespace().ToString();
                            }
                            else
                            {
                                appXamlCsContent = new ApplicationStartupRewriter(edmxName, rootNamespace, clientContextNamespace, clientContextInterfacesNamespace, first: false).Visit(SyntaxFactory.ParseCompilationUnit(appXamlCsContent)).NormalizeWhitespace().ToString();
                            }
                            using (var sw = new StreamWriter(appXamlCsFilePath))
                            {
                                sw.Write(appXamlCsContent);
                            }
                        }


                        string appFilePath = Path.Combine(projectDirectoryPath, "app.config");
                        if (!File.Exists(appFilePath))
                        {
                            CopyFile(Path.Combine(toolsClientWPFPath, "app.config"), appFilePath);
                        }

                        XElement clientConfig = XElement.Load(appFilePath);
                        XElement serviceModel = clientConfig.Element("system.serviceModel");
                        XElement bindings;
                        XElement customBinding;
                        if (serviceModel == null)
                        {
                            clientConfig.Add(serviceModel = new XElement("system.serviceModel", new XElement("bindings", customBinding = new XElement("customBinding"))));
                        }
                        else if ((bindings = serviceModel.Element("bindings")) == null)
                        {
                            serviceModel.Add(new XElement("bindings", customBinding = new XElement("customBinding")));
                        }
                        else if ((customBinding = bindings.Element("customBinding")) == null)
                        {
                            bindings.Add(customBinding = new XElement("customBinding"));
                        }

                        customBinding.Add(
                            new XElement("binding",
                                         new XAttribute("name", string.Format("CustomBinding_I{0}Service", edmxName)),
                                         new XElement("binaryMessageEncoding",
                                                      new XAttribute("maxReadPoolSize", "2147483647"),
                                                      new XAttribute("maxWritePoolSize", "2147483647"),
                                                      new XAttribute("maxSessionSize", "2147483647"),
                                                      new XElement("readerQuotas",
                                                                   new XAttribute("maxDepth", "2147483647"),
                                                                   new XAttribute("maxStringContentLength", "2147483647"),
                                                                   new XAttribute("maxArrayLength", "2147483647"),
                                                                   new XAttribute("maxBytesPerRead", "2147483647"),
                                                                   new XAttribute("maxNameTableCharCount", "2147483647"))),
                                         new XElement("httpTransport",
                                                      new XAttribute("manualAddressing", "false"),
                                                      new XAttribute("maxBufferPoolSize", "2147483647"),
                                                      new XAttribute("maxReceivedMessageSize", "2147483647"),
                                                      new XAttribute("allowCookies", "false"),
                                                      new XAttribute("authenticationScheme", "Anonymous"),
                                                      new XAttribute("bypassProxyOnLocal", "false"),
                                                      new XAttribute("decompressionEnabled", "true"),
                                                      new XAttribute("hostNameComparisonMode", "StrongWildcard"),
                                                      new XAttribute("keepAliveEnabled", "true"),
                                                      new XAttribute("maxBufferSize", "2147483647"),
                                                      new XAttribute("proxyAuthenticationScheme", "Anonymous"),
                                                      new XAttribute("realm", ""),
                                                      new XAttribute("transferMode", "Buffered"),
                                                      new XAttribute("unsafeConnectionNtlmAuthentication", "false"),
                                                      new XAttribute("useDefaultWebProxy", "true"))));
                        XElement client;
                        if ((client = serviceModel.Element("client")) == null)
                        {
                            serviceModel.Add(client = new XElement("client"));
                        }
                        client.Add(
                            new XElement("endpoint",
                                         new XAttribute("address", svcUrl),
                                         new XAttribute("binding", "customBinding"),
                                         new XAttribute("bindingConfiguration", string.Format("CustomBinding_I{0}Service", edmxName)),
                                         new XAttribute("contract", string.Format("{0}.I{1}Service", serviceContractNamespace ?? (rootNamespace + ".ClientContext.ServiceReference"), edmxName)),
                                         new XAttribute("name", string.Format("CustomBinding_I{0}Service", edmxName))));
                        clientConfig.Save(appFilePath);
                    }

                    Directory.CreateDirectory(waqsDirectory);

                    string toolsWaqsPath = null;
                    switch (kind)
                    {
                    case "All":
                    case "WithoutGlobal":
                        toolsWaqsPath = Path.Combine(toolsClientWPFPath, "Client.WPF.waqs");
                        break;

                    case "WithoutFramework":
                    case "WithoutGlobalWithoutFramework":
                        toolsWaqsPath = Path.Combine(toolsClientWPFPath, "ClientWithoutFramework.WPF.waqs");
                        break;

                    case "FrameworkOnly":
                        toolsWaqsPath = Path.Combine(toolsClientWPFPath, "ClientFrameworkOnly.WPF.waqs");
                        edmxName      = "Framework";
                        break;

                    case "GlobalOnly":
                        toolsWaqsPath = Path.Combine(toolsClientWPFPath, "ClientGlobalOnly.WPF.waqs");
                        break;
                    }
                    string clientWPFWAQS = Path.Combine(waqsDirectory, edmxName + ".Client.WPF.waqs");
                    if (toolsWaqsPath != null)
                    {
                        if (!File.Exists(clientWPFWAQS))
                        {
                            serverEntitiesSolutionPath = GetRelativePath(serverEntitiesSolutionPath, waqsDirectory);
                            serverEntitiesProjectPath  = GetRelativePath(serverEntitiesProjectPath, waqsDirectory);
                            var slnRelativeFilePath = GetRelativePath(slnFilePath, waqsDirectory);
                            specificationsCsprojPath = GetRelativePath(specificationsCsprojPath, waqsDirectory);
                            specificationsFolderPath = GetRelativePath(specificationsFolderPath, waqsDirectory);
                            serverEntitiesFolderPath = GetRelativePath(serverEntitiesFolderPath, waqsDirectory);
                            dtoSlnFilePath           = GetRelativePath(dtoSlnFilePath, waqsDirectory);
                            dtoCsprojPath            = GetRelativePath(dtoCsprojPath, waqsDirectory);
                            dtoFolderPath            = GetRelativePath(dtoFolderPath, waqsDirectory);
                            CopyFile(toolsWaqsPath, clientWPFWAQS, new[] { "$edmxPath$", edmxPath.Contains(":") ? GetRelativePath(edmxPath, waqsDirectory) : "..\\" + edmxPath }, new[] { "$svcUrl$", svcUrl }, new[] { "$EntitiesNamespace$", entitiesNamespace }, new[] { "$ClientContextNamespace$", clientContextNamespace }, new[] { "$ClientContextInterfacesNamespace$", clientContextInterfacesNamespace }, new[] { "$SpecificationsSlnFilePath$", slnRelativeFilePath }, new[] { "$SpecificationsCsprojPath$", specificationsCsprojPath }, new[] { "$SpecificationsFolderPath$", specificationsFolderPath + "\\" }, new[] { "$DTOSlnFilePath$", dtoSlnFilePath }, new[] { "$DTOCsprojPath$", dtoCsprojPath }, new[] { "$DTOFolderPath$", dtoFolderPath + "\\" }, new[] { "$ServerEntitiesSlnFilePath$", serverEntitiesSolutionPath }, new[] { "$ServerEntitiesCsprojPath$", serverEntitiesProjectPath }, new[] { "$ServerEntitiesFolderPath$", serverEntitiesFolderPath + "\\" }, new[] { "$ServerEntitiesNamespace$", serverEntitiesNamespace });
                        }

                        if (kind != "GlobalOnly")
                        {
                            string clientWPFTT = Path.Combine(waqsDirectory, edmxName + ".Client.WPF.tt");
                            if (!File.Exists(clientWPFTT))
                            {
                                CopyTTFile(Path.Combine(toolsClientWPFPath, "Client.WPF.tt"), clientWPFTT, sourceControl, slnTTIncludesPath, new[] { "$edmxName$", edmxName }, new[] { "$RootNamespace$", rootNamespace }, new[] { "$NetVersion$", netVersion }, new[] { "$VSVersion$", vsVersion });
                            }
                        }
                    }

                    if (sourceControl)
                    {
                        string ttIncludesSourcePath   = Path.Combine(Path.GetDirectoryName(toolsClientWPFPath), "ttincludes");
                        string slnLocalTTIncludesPath = Path.Combine(Path.GetDirectoryName(slnFilePath), "WPFClientTemplates");
                        if (!Directory.Exists(slnLocalTTIncludesPath))
                        {
                            Directory.CreateDirectory(slnLocalTTIncludesPath);
                        }
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                        ttIncludesSourcePath = Path.Combine(ttIncludesSourcePath, vsVersion);
                        CopyTTIncludes(vsVersion, netVersion, ttIncludesSourcePath, slnLocalTTIncludesPath);
                    }
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }