Create Project/solution in an existing directory?

前端 未结 6 1364
南方客
南方客 2021-02-04 00:03

How can I create a New project & Solution in the same, existing , directory? No matter what I do, it keeps creating a new (sub)directory for the project and populating that

6条回答
  •  误落风尘
    2021-02-04 00:51

                public static class SlnFileGenerator
                {
                    #region Public Methods
                    public static string GetBatFileContent(string directoryPath, string slnFileName)
                    {
                        if (directoryPath == null)
                        {
                            throw new ArgumentNullException(nameof(directoryPath));
                        }
    
                        if (slnFileName == null)
                        {
                            throw new ArgumentNullException(nameof(slnFileName));
                        }
    
                        var sb = new StringBuilder();
                        sb.AppendLine($"dotnet new sln --name {slnFileName}");
    
                        foreach (var csprojFile in Directory.GetFiles(directoryPath, "*.csproj", SearchOption.AllDirectories))
                        {
                            var relativePath = csprojFile.RemoveFromStart(directoryPath);
    
                            sb.AppendLine($"dotnet sln \"{slnFileName}.sln\" add \"{relativePath}\"");
                        }
    
                        sb.AppendLine("pause");
    
                        return sb.ToString();
                    }
                    #endregion
                }
    

提交回复
热议问题