public static ProjInfo ProjInfoFrom(string csProjPath) { using (var fileStream = File.Open(csProjPath, FileMode.Open)) { XmlSerializer serializer = new XmlSerializer(typeof(OldStyleCsProj.Project)); var parsed = (OldStyleCsProj.Project)serializer.Deserialize(fileStream); ProjectPropertyGroup mainPG = parsed.Items .Where(item => item.GetType() == typeof(OldStyleCsProj.ProjectPropertyGroup)) ?.Select(item => item as OldStyleCsProj.ProjectPropertyGroup) .FirstOrDefault(propertyGroup => !string.IsNullOrWhiteSpace(propertyGroup.AssemblyName)); return(new ProjInfo { AssType = ResolveOutputType(mainPG.OutputType), AssName = mainPG.AssemblyName, CsProjPath = csProjPath, Description = mainPG.Description, GeneratePackage = mainPG.GeneratePackageOnBuildSpecified ? mainPG.GeneratePackageOnBuild : false, PackageId = mainPG.PackageId, RepositoryUrl = mainPG.RepositoryUrl, TargetFrameworks = mainPG.TargetFrameworkVersion ?? mainPG.TargetFrameworks, }); } }
public override void GetProjectItems(ModuleDefinition module, Action <ModuleDefinition> createProjectReferences) { bool shouldAddVisualBasicItems = this.language is IVisualBasic && this.projectType != WinRTProjectType.ComponentForUniversal; this.projectItems = new List <object>(); this.projectItems.Add(this.GenerateCommonPropsProjectImportProperty()); this.GetModuleSpecificProperties(module.IsMain); createProjectReferences(module); this.projectItems.Add(this.projectReferences); if (this.projectType == WinRTProjectType.ComponentForUniversal) { ProjectItemGroup targetPlatform = new ProjectItemGroup() { TargetPlatform = new ProjectItemGroupTargetPlatform[] { new ProjectItemGroupTargetPlatform() { Include = "WindowsPhoneApp, Version=8.1" }, new ProjectItemGroupTargetPlatform() { Include = "Windows, Version=8.1" } } }; this.projectItems.Add(targetPlatform); } this.projectItems.Add(this.GetProjectItemsItemGroup()); if (this.projectType != WinRTProjectType.ComponentForUniversal) { this.projectItems.Add(this.GetVisualStudioVersionPropertyGroup()); } if (this.projectType == WinRTProjectType.ComponentForWindowsPhone) { ProjectPropertyGroup targetPlatformIdentifier = new ProjectPropertyGroup() { Condition = " '$(TargetPlatformIdentifier)' == '' ", TargetPlatformIdentifier = "WindowsPhoneApp" }; this.projectItems.Add(targetPlatformIdentifier); } if (shouldAddVisualBasicItems) { this.projectItems.Add(this.GetCompileOptions()); } this.projectItems.Add(this.GenerateLanguageTargetsProjectImportProperty()); this.project.Items = this.projectItems.ToArray(); }
private void AddAdditionalProjectProperties(ProjectPropertyGroup project) { project.ProjectTypeGuids = this.GetProjectTypeGuids(this.assembly.MainModule); project.MinimumVisualStudioVersion = this.GetMinimumVisualStudioVersion(); project.TargetPlatformVersion = this.GetTargetPlatformVersion(); project.TargetFrameworkProfile = this.GetTargetFrameworkProfile(); }
protected virtual void GetModuleSpecificProperties(bool isMainModule) { ProjectPropertyGroup moduleBasicProperties = isMainModule ? this.mainModulebasicProjectProperties : this.netModulebasicProjectProperties; this.projectItems.Add(moduleBasicProperties); this.projectItems.Add(this.GetConfiguration(moduleBasicProperties.Platform.Value, true)); // Debug this.projectItems.Add(this.GetConfiguration(moduleBasicProperties.Platform.Value, false)); // Release }
protected override ProjectPropertyGroup GetNetmoduleBasicProjectProperties(ModuleDefinition module) { ProjectPropertyGroup result = base.GetNetmoduleBasicProjectProperties(module); this.AddAdditionalProjectProperties(result); return(result); }
protected override ProjectPropertyGroup GetMainModuleBasicProjectProperties() { ProjectPropertyGroup result = base.GetMainModuleBasicProjectProperties(); this.AddAdditionalProjectProperties(result); return(result); }
protected virtual object GetConfiguration(string platform, bool debugConfiguration) { ProjectPropertyGroup result = new ProjectPropertyGroup(); if (debugConfiguration) { result.Condition = " '$(Configuration)|$(Platform)' == 'Debug|" + platform + "' "; result.DebugSymbols = true; result.DebugType = "full"; result.Optimize = false; result.OutputPath = GetOutputPath(platform, debugConfiguration); } else { result.Condition = " '$(Configuration)|$(Platform)' == 'Release|" + platform + "' "; result.DebugSymbols = false; result.DebugType = "pdbonly"; result.Optimize = true; result.OutputPath = GetOutputPath(platform, debugConfiguration); } string separator = this.language is IVisualBasic ? "," : ";"; string defineConstants = string.Join(separator, this.GetConfigurationConstants(debugConfiguration)); if (defineConstants != string.Empty) { result.DefineConstants = defineConstants; } if (this.language is ICSharp) { result.ErrorReport = "prompt"; result.WarningLevel = 4; result.WarningLevelSpecified = true; } else if (this.language is IVisualBasic) { result.DefineDebug = debugConfiguration; result.DefineDebugSpecified = true; result.DefineTrace = true; result.DefineTraceSpecified = true; result.DocumentationFile = string.Format("{0}.xml", this.assembly.Name.Name); result.NoWarn = string.Join(",", this.GetWarningConfigurations()); } else { throw new NotSupportedException(); } result.PlatformTarget = platform; result.OptimizeSpecified = true; result.DebugSymbolsSpecified = true; return(result); }
private ProjectPropertyGroup[] GetConfigurations(ProjectPropertyGroup basicProjectProperties) { ProjectPropertyGroup[] configurations = new ProjectPropertyGroup[2]; // Debug + Release configurations[0] = this.CreateConfiguration(basicProjectProperties.Platform.Value, true); configurations[1] = this.CreateConfiguration(basicProjectProperties.Platform.Value, false); return(configurations); }
protected virtual object GetCompileOptions() { ProjectPropertyGroup compileOptions = new ProjectPropertyGroup() { OptionExplicit = "On", OptionCompare = "Binary", OptionStrict = "Off", OptionInfer = "On" }; return(compileOptions); }
protected virtual void GetNetModuleBasicProjectProperties(ModuleDefinition netModule) { if (netModule.Kind != ModuleKind.NetModule) { throw new Exception("Unexpected type of module."); } string projectGuid = this.WriteProjectGuid(this.modulesProjectsGuids, netModule); string moduleName = Utilities.GetNetmoduleName(netModule); this.netModulebasicProjectProperties = this.GetBasicProjectPropertiesInternal(netModule, moduleName, projectGuid); }
private void AddAdditionalProjectProperties(ProjectPropertyGroup project) { project.ProjectTypeGuids = this.GetProjectTypeGuids(this.assembly.MainModule); project.MinimumVisualStudioVersion = this.GetMinimumVisualStudioVersion(); project.TargetPlatformVersion = this.GetTargetPlatformVersion(); project.TargetFrameworkProfile = this.GetTargetFrameworkProfile(); if (IsUWPProject) { project.TargetPlatformMinVersion = this.minInstalledUAPVersion.ToString(); project.TargetPlatformIdentifier = UAPPlatformIdentifier; } project.AllowCrossPlatformRetargeting = false; project.AllowCrossPlatformRetargetingSpecified = this.projectType == WinRTProjectType.UWPComponent; }
protected override ProjectPropertyGroup CreateConfiguration(string platform, bool debugConfiguration) { ProjectPropertyGroup config = base.CreateConfiguration(platform, debugConfiguration); config.UseVSHostingProcess = false; config.UseVSHostingProcessSpecified = true; config.Prefer32Bit = true; config.Prefer32BitSpecified = true; if (this.language is CSharp) { config.NoWarn = ";2008"; config.WarningLevelSpecified = false; } return(config); }
private ProjectPropertyGroup GetBasicProjectPropertiesInternal(ModuleDefinition module, string assemblyName, string projectGuid) { ProjectPropertyGroup basicProjectProperties = new ProjectPropertyGroup() { TargetFrameworkVersion = this.GetTargetFrameworkVersion(module), AssemblyName = assemblyName, OutputType = this.GetOutputType(module), Platform = new ProjectPropertyGroupPlatform() { Condition = " '$(Platform)' == '' ", Value = Utilities.GetModuleArchitecturePropertyValue(module) }, Configuration = new ProjectPropertyGroupConfiguration() { Condition = " '$(Configuration)' == '' ", Value = "Debug" } }; basicProjectProperties.ProjectGuid = "{" + projectGuid + "}"; if (this.visualStudioVersion == VisualStudioVersion.VS2010) { basicProjectProperties.SchemaVersion = (decimal)2.0; //constant in VS 2010 basicProjectProperties.SchemaVersionSpecified = true; //constant in VS 2010roperties.ProjectType //basicProjectProperties.SchemaVersionSpecified //basicProjectProperties.ProductVersion - the version of the project template VS used to create the project file } // VB compiler injects RootNamespace in all types // so we let it stay in the source code and remove it from the project settings if (!(this.language is IVisualBasic)) { basicProjectProperties.RootNamespace = this.NamespacesTree.RootNamespace; } basicProjectProperties.AutoGenerateBindingRedirects = IsAutoGenerateBindingRedirectsSupported(module); basicProjectProperties.AutoGenerateBindingRedirectsSpecified = basicProjectProperties.AutoGenerateBindingRedirects; return(basicProjectProperties); }
protected override object GetConfiguration(string platform, bool debugConfiguration) { ProjectPropertyGroup configuration = (base.GetConfiguration(platform, debugConfiguration) as ProjectPropertyGroup); configuration.UseVSHostingProcess = false; configuration.UseVSHostingProcessSpecified = true; if (this.IsApplicationProject() && platform == "AnyCPU") { configuration.Prefer32Bit = true; configuration.Prefer32BitSpecified = true; } if (this.language is ICSharp) { configuration.NoWarn = ";2008"; configuration.WarningLevelSpecified = false; } else if (this.language is IVisualBasic) { if (debugConfiguration) { configuration.NoConfig = true; configuration.NoConfigSpecified = true; } else { configuration.NoStdLib = true; configuration.NoStdLibSpecified = true; configuration.NoConfig = true; configuration.NoConfigSpecified = true; } } if (this.projectType == WinRTProjectType.UWPApplication) { configuration.UseDotNetNativeToolchain = !debugConfiguration; configuration.UseDotNetNativeToolchainSpecified = true; } return(configuration); }
private bool Match(ProjectPropertyGroup group) { switch (this.Type) { case ConfigurationType.All: return(true); case ConfigurationType.Global: return(group.Global); case ConfigurationType.Release: return(group.Release); case ConfigurationType.Debug: return(group.Debug); default: throw new ArgumentOutOfRangeException(); } }
internal override void UpdateEnvironmentVariables() { base.UpdateEnvironmentVariables(); EnvironmentVariables["$(Configuration)"] = Configuration; EnvironmentVariables["$(Platform)"] = Platform; if (null != ProjectPropertyGroup) { ProjectPropertyGroup.UpdateEnvironmentVariables(); } if (null != ProjectItemDefinitionGroup) { ProjectItemDefinitionGroup.UpdateEnvironmentVariables(); } if (null != ProjectImportGroup) { ProjectImportGroup.UpdateEnvironmentVariables(); } }
private ProjectPropertyGroup[] GetConfigurations(ProjectPropertyGroup basicProjectProperties) { int i = 0; ProjectPropertyGroup[] configurations = new ProjectPropertyGroup[this.platforms.Count * 2]; foreach (string platform in this.platforms) { if (platform == "Any CPU") { ProjectPropertyGroup configuration; bool isVisualBasic = this.language is VisualBasic; configuration = base.CreateConfiguration("AnyCPU", true); //Debug if (isVisualBasic) { configuration.NoConfig = true; configuration.NoConfigSpecified = true; } configurations[i++] = configuration; configuration = base.CreateConfiguration("AnyCPU", false); //Release if (isVisualBasic) { configuration.NoStdLib = true; configuration.NoStdLibSpecified = true; configuration.NoConfig = true; configuration.NoConfigSpecified = true; } configurations[i++] = configuration; } else { configurations[i++] = this.CreateConfiguration(platform, true); configurations[i++] = this.CreateConfiguration(platform, false); } } return(configurations); }
protected override object[] GetProjectItems(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { bool shouldAddVisualBasicItems = this.language is IVisualBasic && this.projectType != WinRTProjectType.ComponentForUniversal; object[] items = new object[GetNumberOfProjectItems(shouldAddVisualBasicItems)]; int currentItem = 0; items[currentItem++] = this.GenerateCommonPropsProjectImportProperty(); items[currentItem++] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int j = 0; j < configurations.Length; j++) { items[currentItem++] = configurations[j]; } items[currentItem++] = this.CreatePojectReferences(module, basicProjectProperties); if (this.projectType == WinRTProjectType.ComponentForUniversal) { items[currentItem++] = new ProjectItemGroup() { TargetPlatform = new ProjectItemGroupTargetPlatform[] { new ProjectItemGroupTargetPlatform() { Include = "WindowsPhoneApp, Version=8.1" }, new ProjectItemGroupTargetPlatform() { Include = "Windows, Version=8.1" } } }; } items[currentItem++] = this.fileGenContext.GetProjectItemGroup(); if (this.projectType != WinRTProjectType.ComponentForUniversal) { items[currentItem++] = this.GetVisualStudioVersionPropertyGroup(); } if (this.projectType == WinRTProjectType.ComponentForWindowsPhone) { items[currentItem++] = new ProjectPropertyGroup() { Condition = " '$(TargetPlatformIdentifier)' == '' ", TargetPlatformIdentifier = "WindowsPhoneApp" }; } if (shouldAddVisualBasicItems) { items[currentItem++] = this.GetCompileOptions(); } items[currentItem++] = this.GenerateLanguageTargetsProjectImportProperty(); return(items); }
protected override ProjectItemGroup CreatePojectReferences(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { ProjectItemGroup result = base.CreatePojectReferences(module, basicProjectProperties); if (IsUWPProject) { result.None = new ProjectItemGroupNone() { Include = ProjectJsonWriter.ProjectJsonFileName }; } return(result); }
protected override object[] GetProjectItems(ModuleDefinition module, ProjectPropertyGroup basicProjectProperties) { object[] items = null; bool isVisualBasic = this.language is VisualBasic; if (this.projectType == WinRTProjectType.Component || this.projectType == WinRTProjectType.ComponentForWindows) { items = isVisualBasic ? new object[15] : new object[14]; int i = 0; items[i++] = this.GenerateCommonPropsProjectImportProperty(); items[i++] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int j = 0; j < configurations.Length; j++, i++) { items[j + 2] = configurations[j]; } items[i++] = this.CreatePojectReferences(module, basicProjectProperties); items[i++] = this.fileGenContext.GetProjectItemGroup(); items[i++] = this.GetVisualStudioVersionPropertyGroup(); if (isVisualBasic) { items[i++] = this.GetCompileOptions(); } items[i++] = this.GenerateLanguageTargetsProjectImportProperty(); } else if (this.projectType == WinRTProjectType.ComponentForUniversal) { items = new object[8]; items[0] = this.GenerateCommonPropsProjectImportProperty(); items[1] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int i = 0; i < configurations.Length; i++) { items[i + 2] = configurations[i]; } items[4] = this.CreatePojectReferences(module, basicProjectProperties); items[5] = new ProjectItemGroup() { TargetPlatform = new ProjectItemGroupTargetPlatform[] { new ProjectItemGroupTargetPlatform() { Include = "WindowsPhoneApp, Version=8.1" }, new ProjectItemGroupTargetPlatform() { Include = "Windows, Version=8.1" } } }; items[6] = this.fileGenContext.GetProjectItemGroup(); items[7] = this.GenerateLanguageTargetsProjectImportProperty(); } else if (this.projectType == WinRTProjectType.ComponentForWindowsPhone) { items = isVisualBasic ? new object[14] : new object[13]; int i = 0; items[i++] = this.GenerateCommonPropsProjectImportProperty(); items[i++] = basicProjectProperties; object[] configurations = this.GetConfigurations(basicProjectProperties); for (int j = 0; j < configurations.Length; j++, i++) { items[j + 2] = configurations[j]; } items[i++] = this.CreatePojectReferences(module, basicProjectProperties); items[i++] = this.fileGenContext.GetProjectItemGroup(); items[i++] = this.GetVisualStudioVersionPropertyGroup(); items[i++] = new ProjectPropertyGroup() { Condition = " '$(TargetPlatformIdentifier)' == '' ", TargetPlatformIdentifier = "WindowsPhoneApp" }; if (isVisualBasic) { items[i++] = this.GetCompileOptions(); } items[i++] = this.GenerateLanguageTargetsProjectImportProperty(); } return(items); }
public override void GetMainModuleBasicProjectProperties() { string projectGuid = this.WriteProjectGuid(this.modulesProjectsGuids, this.assembly.MainModule); this.mainModulebasicProjectProperties = this.GetBasicProjectPropertiesInternal(this.assembly.MainModule, this.assembly.Name.Name, projectGuid.ToUpper()); }