Example #1
0
 public VisualStudioSolution(FileDescriptor file)
     : this(file, null)
 {
     if (!VisualStudioUtils.FindEditorVersion(out version))
     {
         throw new ArgumentOutOfRangeException("Visual Studio Target Version");
     }
 }
 public VisualStudio2012Solution()
     : base(VisualStudioUtils.GetEditorVersion(VisualStudioVersionFlag.VisualStudio2012))
 {
 }
Example #3
0
 public VisualSharp2013()
     : base(VisualStudioUtils.GetEditorVersion(VisualStudioVersionFlag.VisualStudio2013))
 {
 }
Example #4
0
 public VisualCpp2015()
     : base(VisualStudioUtils.GetEditorVersion(VisualStudioVersionFlag.VisualStudio2015))
 {
 }
Example #5
0
        public override void CreateFile()
        {
            using (FileStream fs = Open(FileMode.Create, FileAccess.Write, FileShare.Read))
            {
                if (propertiesPath == null)
                {
                    propertiesPath = new PathDescriptor(location, "Properties");
                }

                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine("<Project ToolsVersion=\"{0}\" DefaultTargets=\"{1}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">", VisualStudioUtils.GetToolsVersion(version), "Build");

                SetConfigHeader(sw);
                SetBuildTargets(sw);
                SetReferences(sw);
                SetSourceFiles(sw);
                SetEmbeddedResources(sw);

                sw.WriteLine("  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />");
                sw.WriteLine("</Project>");
                sw.Flush();
            }
        }
Example #6
0
        protected void SetTargetConfiguration(StreamWriter writer)
        {
            writer.WriteLine("  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />");

            string projectType;

            switch (outputType)
            {
            case OutputAssemblyType.Console:
            case OutputAssemblyType.Executable: projectType = "Application"; break;

            case OutputAssemblyType.Library: projectType = "DynamicLibrary"; break;

            case OutputAssemblyType.Static:
            default: projectType = "StaticLibrary"; break;
            }
            string extension;

            switch (outputType)
            {
            case OutputAssemblyType.Console:
            case OutputAssemblyType.Executable: extension = ".exe"; break;

            case OutputAssemblyType.Library: extension = ".dll"; break;

            case OutputAssemblyType.Static:
            default: extension = ".lib"; break;
            }
            foreach (BuildTarget target in buildTargets)
            {
                writer.WriteLine("  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\" Label=\"Configuration\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <ConfigurationType>{0}</ConfigurationType>", projectType);
                writer.WriteLine("    <UseDebugLibraries>{0}</UseDebugLibraries>", (target.Mode.Optimized) ? "false" : "true");
                writer.WriteLine("    <PlatformToolset>{0}</PlatformToolset>", VisualStudioUtils.GetToolsetVersion(version));
                writer.WriteLine("  </PropertyGroup>");

                writer.WriteLine("  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <OutDir>{0}</OutDir>", outputPath.GetRelativePath(location));
                writer.WriteLine("    <IntDir>{0}$(ProjectName)\\</IntDir>", Application.BuildDirectory.GetRelativePath(location));
                writer.WriteLine("    <TargetName>{0}</TargetName>", assemblyName);
                writer.WriteLine("    <TargetExt>{0}</TargetExt>", extension);
                writer.WriteLine("  </PropertyGroup>");

                writer.WriteLine("  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />");
                writer.WriteLine("  </ImportGroup>");

                writer.WriteLine("  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <ClCompile>");

                writer.Write("      <AdditionalIncludeDirectories>");
                writer.Write("$(ProjectDir);");
                foreach (VisualStudioProject reference in DependencyProjects)
                {
                    writer.Write("$(ProjectDir)");
                    writer.Write(reference.Location.GetRelativePath(location));
                    writer.Write(";");
                }
                writer.WriteLine("</AdditionalIncludeDirectories>");

                writer.Write("      <PreprocessorDefinitions>");
                foreach (KeyValuePair <string, object> definitions in target.Mode.Definitions)
                {
                    writer.Write(definitions.Key);
                    writer.Write(";");
                }
                writer.WriteLine("</PreprocessorDefinitions>");
                writer.WriteLine("      <WarningLevel>Level4</WarningLevel>");
                writer.WriteLine("      <TreatWarningAsError>{0}</TreatWarningAsError>", (target.Mode.WarningAsError) ? "true" : "false");
                writer.WriteLine("      <ExceptionHandling>false</ExceptionHandling>");

                if (target.Mode.Optimized)
                {
                    writer.WriteLine("      <Optimization>MaxSpeed</Optimization>");
                }

                writer.WriteLine("    </ClCompile>");
                writer.WriteLine("    <Link>");

                HashSet <UInt32> directories = new HashSet <UInt32>();
                writer.Write("      <AdditionalLibraryDirectories>");
                foreach (VisualStudioProject reference in DependencyProjects)
                {
                    UInt32 id = reference.OutputPath.GetAbsolutePath().Fnv32();
                    if (!directories.Contains(id))
                    {
                        writer.Write("$(ProjectDir)\\");
                        writer.Write(reference.OutputPath.GetRelativePath(location));
                        writer.Write(";");
                        directories.Add(id);
                    }
                }
                writer.WriteLine("</AdditionalLibraryDirectories>");
                writer.Write("      <AdditionalDependencies>");
                foreach (VisualStudioProject reference in DependencyProjects)
                {
                    string depExtension;
                    switch (reference.OutputType)
                    {
                    case OutputAssemblyType.Console:
                    case OutputAssemblyType.Executable: depExtension = ".exe"; break;

                    case OutputAssemblyType.Library: depExtension = ".dll"; break;

                    case OutputAssemblyType.Static:
                    default: depExtension = ".lib"; break;
                    }

                    writer.Write("{0}{1}", reference.AssemblyName, depExtension);
                    writer.Write(";");
                }
                foreach (FileDescriptor external in dependencies)
                {
                    writer.Write(external.FullName);
                    writer.Write(";");
                }
                writer.WriteLine("</AdditionalDependencies>");

                writer.WriteLine("      <GenerateDebugInformation>{0}</GenerateDebugInformation>", target.Mode.SymbolExport);
                writer.WriteLine("    </Link>");

                writer.WriteLine("  </ItemDefinitionGroup>");
            }

            writer.WriteLine("  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />");
            writer.WriteLine("  <ImportGroup Label=\"ExtensionSettings\">");
            writer.WriteLine("    <Import Project=\"$(VCTargetsPath)\\BuildCustomizations\\masm.props\" />");
            writer.WriteLine("  </ImportGroup>");
        }
Example #7
0
        public override void CreateFile()
        {
            if (!Application.BuildDirectory.Exists())
            {
                Application.BuildDirectory.CreateHidden();
            }

            using (FileStream fs = Open(FileMode.Create, FileAccess.Write, FileShare.Read))
            {
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                sw.WriteLine("<Project ToolsVersion=\"{0}\" DefaultTargets=\"{1}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">", VisualStudioUtils.GetToolsVersion(version), "Build");
                sw.WriteLine("  <PropertyGroup Label=\"Globals\">");
                sw.WriteLine("    <ProjectGuid>{0}</ProjectGuid>", projectGuid.ToString("B").ToUpperInvariant());
                sw.WriteLine("  </PropertyGroup>");

                SetBuildTargets(sw);
                SetProjectFiles(sw);
                SetTargetConfiguration(sw);
                SetTargetImports(sw);

                sw.WriteLine("</Project>");
                sw.Flush();
            }
            using (FileStream fs = new FileDescriptor(location, "{0}.filters", FullName).Open(FileMode.Create, FileAccess.Write, FileShare.Read))
            {
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                sw.WriteLine("<Project ToolsVersion=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">", VisualStudioUtils.GetToolsVersion(version));

                sw.WriteLine("  <ItemGroup>");
                SetFilterDirectories(location, sw);
                sw.WriteLine("  </ItemGroup>");
                SetFilterFiles(sw);

                sw.WriteLine("</Project>");
                sw.Flush();
            }
        }