コード例 #1
0
 private void WriteFilesForTfs(ProjectFile project, FileToWrite file)
 {
     Log("Processing file: " + file.Path);
     if (File.Exists(file.Path))
     {
         var tfsFile = File.ReadAllText(file.Path);
         if (tfsFile.Equals(file.Contents))
         {
             Log(tfsFile);
             Log(file.Contents);
             Log(file.Path + " was unchanged.");
             return;
         }
         file.TempFile = Path.Combine(file.Directory, "zzzTempEarlyBoundGenerator." + Path.GetFileName(file.Path) + ".tmp");
         Log("Creating Temp File " + file.TempFile);
         File.WriteAllText(file.TempFile, file.Contents);
         file.HasChanged = true;
     }
     else
     {
         File.WriteAllText(file.Path, file.Contents);
         Tfs.Add(file.Path);
         Console.WriteLine(file.Path + " created.");
         project.AddFileIfMissing(file.Path);
     }
 }
        public void RunFinished()
        {
            var projectFullName = Project.FullName;

            Dte.Solution.Remove(Project);
            var fInfoProject = new FileInfo(projectFullName);
            var dInfoProject = new DirectoryInfo(fInfoProject.DirectoryName ?? throw new InvalidOperationException());
            var folder       = dInfoProject.Parent?.FullName + "\\" + ProjectName;

            Utility.TryDeleteDirectory(folder);
            dInfoProject.MoveTo(folder);
            Dte.Solution.SaveAs(Dte.Solution.FullName);
            var tfs = new Tfs(Dte);

            tfs.Undo(fInfoProject.DirectoryName);

            Utility.TryDeleteDirectory(folder + "\\bin");
            Utility.TryDeleteDirectory(folder + "\\obj");
            Utility.TryDeleteFile(folder + "\\" + ProjectName + ".csproj");
            Utility.TryDeleteFile(folder + "\\" + ProjectName + ".csproj.vspscc");
            Utility.TryDeleteFile(folder + "\\" + ProjectName + ".csproj.user");

            tfs.Add(dInfoProject.FullName);

            Dte.Solution.SaveAs(Dte.Solution.FullName);
            var fullName = Dte.Solution.FullName;

            Port = (Dte.Solution.Projects.Count + 1).ToString();
            UpdateSolutionFile(fullName, ProjectName, NetVersion, Port);
            Dte.Solution.Open(fullName);
        }
コード例 #3
0
        private void WriteFileIfDifferent(ProjectFile project, FileToWrite file)
        {
            Log("Processing file: " + file.Path);
            if (UseTfsToCheckoutFiles)
            {
                if (File.Exists(file.Path))
                {
                    Trace.TraceInformation(Path.GetFileName(file.Path) + " Checking out and updating if different.");
                    var tempFile = Path.Combine(file.Directory, "zzzTempEarlyBoundGenerator." + Path.GetFileName(file.Path) + ".tmp");
                    try
                    {
                        Log("Creating Temp File " + tempFile);
                        File.WriteAllText(tempFile, file.Contents);
                        var hasChanged = Tfs.AreDifferent(file.Path, tempFile);
                        if (hasChanged)
                        {
                            Console.WriteLine($"{file.Path} was changed.  Checking Out from TFS.");
                            Tfs.Checkout(file.Path);
                            Log("Updating File locally");
                            File.Copy(tempFile, file.Path, true);
                        }
                        var message = file.Path + $" was {(hasChanged ? "" : "un")}changed.";
                        if (file.IsMainFile)
                        {
                            Console.WriteLine(message);
                        }
                        else
                        {
                            Log(message);
                        }
                    }
                    finally
                    {
                        File.Delete(tempFile);
                    }
                }
                else
                {
                    File.WriteAllText(file.Path, file.Contents);
                    Tfs.Add(file.Path);
                    Console.WriteLine(file.Path + " created.");
                    project.AddFileIfMissing(file.Path);
                }
                return;
            }

            EnsureFileIsAccessible(file.Path);
            project.AddFileIfMissing(file.Path);

            Trace.TraceInformation(Path.GetFileName(file.Path) + " created / updated.");
            Log("Writing file: " + file.Path);
            File.WriteAllText(file.Path, file.Contents);
            Log("Completed file: " + file);
        }
        public void RunFinished()
        {
            var projectFullName  = Project.FullName;
            var projectFolder    = Path.GetDirectoryName(projectFullName);
            var solutionFullName = Dte?.Solution?.FullName;
            var solutionFolder   = Path.GetDirectoryName(solutionFullName) + "\\" + ProjectName;

            Dte.Solution.Remove(Project);
            Directory.Move(projectFolder, solutionFolder);
            Dte.Solution.AddFromFile(solutionFolder + "\\" + ProjectName + ".shproj");
            Dte.Solution.SaveAs(Dte.Solution.FullName);
            var tfs = new Tfs(Dte);

            tfs.Undo(projectFolder);
            tfs.Add(solutionFolder);
        }
        public void RunFinished()
        {
            var projectFullName = Project.FullName;

            Dte.Solution.Remove(Project);
            var fInfoProject = new FileInfo(projectFullName);
            var dInfoProject = new DirectoryInfo(fInfoProject.DirectoryName ?? throw new InvalidOperationException());
            var folder       = dInfoProject.Parent?.FullName + "\\" + ProjectName;

            Utility.TryDeleteDirectory(folder);
            dInfoProject.MoveTo(folder);
            Dte.Solution.AddFromFile(dInfoProject.Parent?.FullName + "\\" + ProjectName + "\\" + ProjectName + ".csproj");
            Dte.Solution.SaveAs(Dte.Solution.FullName);
            var tfs = new Tfs(Dte);

            tfs.Undo(fInfoProject.DirectoryName);
            tfs.Add(dInfoProject.FullName);
            Dte.ExecuteCommand("SolutionExplorer.Refresh");
        }
コード例 #6
0
 public void RunFinished()
 {
     try
     {
         var projectFullName = Project.FullName;
         Dte.Solution.Remove(Project);
         File.WriteAllText(projectFullName, Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.ReportProjectTemplate.csproj"), System.Text.Encoding.UTF8);
         var fInfoProject = new FileInfo(projectFullName);
         fInfoProject.MoveTo(fInfoProject.DirectoryName + "\\" + ProjectName + ".rptproj");
         var dInfoProject = new DirectoryInfo(fInfoProject.DirectoryName ?? throw new InvalidOperationException());
         var folder       = dInfoProject.Parent?.FullName + "\\" + ProjectName;
         Utility.TryDeleteDirectory(folder);
         dInfoProject.MoveTo(folder);
         Dte.Solution.AddFromFile(dInfoProject.Parent?.FullName + "\\" + ProjectName + "\\" + ProjectName + ".rptproj");
         Dte.Solution.SaveAs(Dte.Solution.FullName);
         var tfs = new Tfs(Dte);
         tfs.Undo(fInfoProject.DirectoryName);
         tfs.Add(dInfoProject.FullName);
     }
     catch { }
 }