public void GivenAssemblyVersionDoesntExist_ReturnDefault(string path)
            {
                var absPath = Path.Combine(Directory.GetCurrentDirectory(), path);
                var sut     = new CsprojFile(absPath);

                sut.AssemblyVersion.ShouldBe("1.0.0");
            }
            public void GivenAssemblyVersionDoesntExist_SetValue_AddsElement(string path, string testFile)
            {
                var absPath = Path.Combine(Directory.GetCurrentDirectory(), path);
                var cpPath  = Path.Combine(Directory.GetCurrentDirectory(), $"{testFile}.csproj");

                try
                {
                    File.Copy(absPath, cpPath);
                    var sut = new CsprojFile(cpPath);
                    sut.AssemblyVersion.ShouldBe("1.0.0");
                    sut.AssemblyVersion = "1.2.3";
                    sut.AssemblyVersion.ShouldBe("1.2.3");
                    sut.Save();

                    var sut2 = new CsprojFile(cpPath);
                    sut2.AssemblyVersion.ShouldBe("1.2.3");
                }
                finally
                {
                    if (File.Exists(cpPath))
                    {
                        File.Delete(cpPath);
                    }
                }
            }
            public void GivenAssemblyVersionExists_ReturnValue(string path)
            {
                var absPath = Path.Combine(Directory.GetCurrentDirectory(), path);
                var sut     = new CsprojFile(absPath);

                sut.AssemblyVersion.ShouldBe("1.2.3");
            }
        public override void Run()
        {
            if (parameters.Count < 1)
            {
                throw new SlipeException("Please specify the project name, syntax: \nslipe create-project {project-name} [-server] [-client]");
            }
            string name = parameters[0];
            string path = "Source/" + name;

            if (targetsModule)
            {
                path = targetModule.path + "/" + path;
            }


            string csProjPath = path + "/" + name + ".csproj";

            if (Directory.Exists(path))
            {
                throw new SlipeException("A directory with this name already exists.");
            }

            Directory.CreateDirectory(path);

            CsprojFile projectFile = new CsprojFile(csProjPath, name, "netcoreapp3.0");

            projectFile.Save();

            SlnFile solution = new SlnFile("Resource.sln");

            solution.AddProject(name, csProjPath);

            SlipeConfigCompileTarget target = targetsModule ? targetModule.compileTargets : config.compileTargets;

            if (options.ContainsKey("server"))
            {
                target.server.Add(name);
            }
            if (options.ContainsKey("client"))
            {
                target.client.Add(name);
            }
        }
Beispiel #5
0
 public string VerticalName()
 => CsprojFile.ResolveVerticalName();