/// <summary> /// Adds the copy ressources information. /// </summary> /// <param name="project">The project.</param> /// <param name="coreOptions">The core options.</param> /// <param name="uniqueOutputPath">if set to <c>true</c> [unique output path].</param> /// <returns></returns> private string AddCopyRessourcesInformation(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions, bool uniqueOutputPath) { var buildBuilder = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); foreach (var currentRessource in _ressourceFinder.ExtractRessourcesFromProject(project.Path)) { if (!string.IsNullOrEmpty(currentRessource)) { string temp; if (!uniqueOutputPath) { // In a non web project, we look in the configuration folder, otherwise in the bin folder if (!project.IsWebProject) temp = string.Format("{0}\\bin\\$(Configuration)\\{1}\\{2}.resources.dll", folder, currentRessource, project.AssemblyName); else temp = string.Format("{0}\\bin\\{1}\\{2}.resources.dll", folder, currentRessource, project.AssemblyName); } else temp = string.Format("(UniqueOutputPath)\\{0}\\{1}.resources.dll", currentRessource, project.AssemblyName); buildBuilder.AppendFormat(" <Copy SourceFiles=\"{0}\" DestinationFolder=\"$(DestinationFolder)\\{1}\" Condition=\"Exists('{0}') AND $(CopyEnabled) AND $(CopyRessources)\" ContinueOnError=\"$(ContinueOnError)\" OverwriteReadOnlyFiles=\"True\" SkipUnchangedFiles=\"True\" />", temp, currentRessource); buildBuilder.AppendLine(); } } return buildBuilder.ToString(); }
/// <summary> /// Call when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildAllTypeTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var buildBuilder = new StringBuilder(); buildBuilder.AppendLine(AddCopyRessourcesInformation(project, coreOptions, false)); return buildBuilder.ToString(); }
/// <summary> /// Call for web project when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildWebProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var buildCommand = new StringBuilder(); buildCommand.AppendLine(String.Format(" <MSBuild Properties=\"Configuration=$(Configuration);Platform=$(PlatformConfig);DefineConstants=THREAD_STATIC_CONTAINER\" Projects=\"{0}\" Targets=\"Build\" StopOnFirstFailure=\"True\" ContinueOnError=\"$(ContinueOnError)\" UnloadProjectsOnCompletion=\"$(UnloadProjectsOnCompletion)\" UseResultsCache=\"$(UseResultsCache)\" >", project.GetRelativeFilePath(coreOptions))); buildCommand.AppendLine(string.Format(" <Output TaskParameter=\"TargetOutputs\" ItemName=\"ProjectArtefacts\"/>")); buildCommand.AppendLine(string.Format(" </MSBuild>")); return buildCommand.ToString(); }
/// <summary> /// Call for web project when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildWebProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var buildBuilder = new StringBuilder(); _options.Transforms.ForEach(t => buildBuilder.AppendLine(AddCopyPackagesInformation(project, coreOptions, false, t))); buildBuilder.AppendLine(AddCopyPackagesInformation(project, coreOptions, false)); return buildBuilder.ToString(); }
/// <summary> /// Call for program projects (exe) when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildExeProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var packageCommand = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); var filename = project.GetRelativeFilePath(coreOptions); var packagingCondition = string.Format("Condition=\"$(GenerateMsDeployPackages) AND Exists('{0}\\bin') \" ", folder); packageCommand.AppendLine(string.Format(" <MakeDir Directories=\"$(MSBuildProjectDirectory)\\{0}\\bin\\Packages\\$(Configuration)\\\" {1} />", folder, packagingCondition)); packageCommand.AppendLine(String.Format(" <Exec Command='\"$(MsDeployLocation)\" -verb:sync -source:contentPath=\"$(MSBuildProjectDirectory)\\{0}\" -dest:package=\"$(MSBuildProjectDirectory)\\{0}\\bin\\Packages\\$(Configuration)\\{1}.zip\" -skip:objectName=filePath,absolutePath=\".*\\.vb|cache.*\" -skip:objectName=dirPath,absolutePath=\"obj\" -skip:objectName=dirPath,absolutePath=\"_Resharper\" -skip:objectName=dirPath,absolutePath=\"Packages\" -skip:xpath=\"//dirPath[count(*)=0]\" -skip:objectName=dirPath,absolutePath=\"_PublishedWebsites\" ' {2} />", folder, Path.GetFileNameWithoutExtension(filename), packagingCondition)); return packageCommand.ToString(); }
/// <summary> /// Called just after the build operation on the <paramref name="project"/> /// </summary> /// <param name="project">The project that was visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string PostVisitBuildTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var deleteBinBuilder = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); if (!project.IsWebProject) deleteBinBuilder.AppendLine(string.Format(" <RemoveDir Directories=\"{0}\\bin\\$(Configuration)\" Condition=\"$(GenerateMsDeployPackages)\" />", folder)); else deleteBinBuilder.AppendLine(string.Format(" <RemoveDir Directories=\"{0}\\bin\" Condition=\"$(GenerateMsDeployPackages)\" />", folder)); return deleteBinBuilder.ToString(); }
public override string VisitCleanTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var cleanBuilder = new StringBuilder(); cleanBuilder.AppendLine(String.Format(" <CleanedFiles Include=\"\\\\?\\$(MSBuildProjectDirectory)\\{0}\\bin\\**;\\\\?\\{0}\\obj\\**;\" />", project.GetRelativeFolderPath(coreOptions))); if (!string.IsNullOrEmpty(_options.CopyOutputTo)) cleanBuilder.AppendLine(String.Format(" <CleanedFiles Include=\"\\\\?\\$(DestinationFolder)\\**\\{0}*\" />", Path.GetFileNameWithoutExtension(project.GetRelativeFilePath(coreOptions)))); if(project.IsWebProject) cleanBuilder.AppendLine(String.Format(" <CleanedServicesFiles Include=\"\\\\?\\$(MSBuildProjectDirectory)\\{0}\\bin\\**;\\\\?\\{0}\\obj\\**;\" />", project.GetRelativeFolderPath(coreOptions))); return cleanBuilder.ToString(); }
/// <summary> /// Call for project library when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildLibraryProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { if (Regex.IsMatch(project.AssemblyName, _options.TestDiscoveryPattern)) { var builder = new StringBuilder(); if (string.IsNullOrEmpty(_options.GlobalTestSettings)) builder.AppendLine(string.Format(" <Exec Command='\"$(MsTestLocation)\" /testcontainer:{0}\\$(TestBinFolder)\\{1}.dll /category:\"$(MsTestCategories)\" /usestderr /detail:errormessage /detail:errorstacktrace /resultsfile:\"{1}\".trx' ContinueOnError=\"$(ContinueOnTestError)\" Condition=\"$(ExecuteTests)\" />", project.GetRelativeFolderPath(coreOptions), project.AssemblyName)); else builder.AppendLine(string.Format(" <Exec Command='\"$(MsTestLocation)\" /testcontainer:{0}\\$(TestBinFolder)\\{1}.dll /runconfig:\"{2}\" /category:\"$(MsTestCategories)\" /usestderr /detail:errormessage /detail:errorstacktrace/resultsfile:\"{1}\".trx' ContinueOnError=\"$(ContinueOnTestError)\" Condition=\"$(ExecuteTests)\" />", project.GetRelativeFolderPath(coreOptions), project.AssemblyName, _options.GlobalTestSettings)); if(_options.GenerateTeamCityTransactionMessage) builder.AppendLine(string.Format("<Message Text=\"##teamcity[importData type='mstest' path='{0}.trx']\"/>", project.AssemblyName)); return builder.ToString(); } return null; }
/// <summary> /// Call for project library when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildLibraryProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var buildCommand = new StringBuilder(); //ExecuteTests string condition = null; if(project.IsTestProject) condition = "Condition=\"$(BuildTestProjects)\""; string customOutputPath = null; if (!string.IsNullOrEmpty(_options.MsBuildFileOuputPath)) customOutputPath = "OutputPath=$(OutputPath)"; buildCommand.AppendLine(String.Format(" <MSBuild Properties=\"Configuration=$(Configuration);Platform=$(PlatformConfig);{0}\" Projects=\"{1}\" Targets=\"$(Action)\" StopOnFirstFailure=\"True\" ContinueOnError=\"$(ContinueOnError)\" UnloadProjectsOnCompletion=\"$(UnloadProjectsOnCompletion)\" UseResultsCache=\"$(UseResultsCache)\" {2} >", customOutputPath, project.GetRelativeFilePath(coreOptions), condition)); buildCommand.AppendLine(string.Format(" <Output TaskParameter=\"TargetOutputs\" ItemName=\"ProjectArtefacts\"/>")); buildCommand.AppendLine(string.Format(" </MSBuild>")); return buildCommand.ToString(); }
/// <summary> /// Call for web project when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildWebProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var packageCommand = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); if (_options.Transforms != null && _options.Transforms.Count > 0) { _options.Transforms.ForEach(t => { packageCommand.AppendLine(string.Format(" <Delete Files=\"$(MSBuildProjectDirectory)\\{0}\\web.temp.{1}.config\" Condition=\"$(GenerateMsDeployPackages) AND Exists('{0}\\web.temp.{1}.config')\" />", folder, t)); packageCommand.AppendLine(string.Format(" <Copy SourceFiles=\"$(MSBuildProjectDirectory)\\{0}\\web.config\" DestinationFiles=\"$(MSBuildProjectDirectory)\\{0}\\web.temp.{1}.config\" Condition=\"$(GenerateMsDeployPackages) AND Exists('{0}\\web.{1}.config')\" />", folder, t)); packageCommand.AppendLine(string.Format(" <TransformXml Source=\"$(MSBuildProjectDirectory)\\{0}\\web.temp.{1}.config\" Transform=\"$(MSBuildProjectDirectory)\\{0}\\web.{1}.config\" Destination=\"$(MSBuildProjectDirectory)\\{0}\\web.transformed.{1}.config\" Condition=\"$(GenerateMsDeployPackages) AND Exists('{0}\\web.{1}.config')\" />", folder, t)); packageCommand.AppendLine(GetMsDeployCommand(project, coreOptions, t, true)); }); } packageCommand.AppendLine(GetMsDeployCommand(project, coreOptions)); return packageCommand.ToString(); }
/// <summary> /// Call when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildAllTypeTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { var buildBuilder = new StringBuilder(); var extensions = new List<String>(); if(_options.CopyConfig) extensions.Add("config"); if(_options.CopyXml) extensions.Add("xml"); if (_options.CopyRessources) { extensions.Add("ressources"); extensions.Add("resx"); } if (project.OutputType == ProjectOutputType.Exe.ToString() || project.OutputType == ProjectOutputType.WinExe.ToString()) { if (_options.CopyExe) extensions.Add("exe"); } else { if(_options.CopyDll) extensions.Add("dll"); } if (_options.CopyPdbs) extensions.Add("pdb"); foreach (var ext in extensions) { var capitalizedExt = char.ToUpper(ext[0]) + ext.Substring(1); buildBuilder.AppendLine(AddCopyInformation(project, coreOptions, capitalizedExt, false)); } return buildBuilder.ToString(); }
/// <summary> /// Parses the visual studio project and return the resulting /// </summary> /// <returns> /// An instance of the class <see cref="VisualStudioProject"/> representing the project /// </returns> public VisualStudioProject Parse(string visualStudioProjectPath) { if (!string.IsNullOrEmpty(visualStudioProjectPath) && !visualStudioProjectPath.Contains(".csproj") && !visualStudioProjectPath.Contains(".vbproj")) throw new ArgumentException("The project path must be either a CSharp project or VBProject", "visualStudioProjectPath"); var xproject = GetProjectAsXDocument(visualStudioProjectPath); if (xproject != null && xproject.Root != null) { var root = xproject.Root; var projectInfo = (from item in root.Elements("PropertyGroup") where !item.HasAttributes && item.Element("ProjectGuid") != null && root.Elements("ItemGroup").Elements("Compile") != null && root.Elements("ItemGroup").Elements("Compile").Any() && item.Element("RootNamespace") != null && item.Element("AssemblyName") != null && item.Element("OutputType") != null select new{ RootNamespace = item.Element("RootNamespace").Value, AssemblyName = item.Element("AssemblyName").Value, ProjectGuid = Guid.Parse(item.Element("ProjectGuid").Value), OutputType = item.Element("OutputType").Value, Path = visualStudioProjectPath }).FirstOrDefault(); if (projectInfo != null) { var result = new VisualStudioProject(projectInfo.ProjectGuid, projectInfo.AssemblyName, projectInfo.RootNamespace, projectInfo.Path){IsWebProject = IsWebBuild(xproject)}; result.Dependencies.AddRange(FindFileReferences(root)); result.Dependencies.AddRange(FindProjectReferences(root)); result.IsTestProject = result.Dependencies.Contains("Microsoft.VisualStudio.QualityTools.UnitTestFramework"); result.OutputType = projectInfo.OutputType; return result; } } return null; }
public OptionsProcessor(VisualStudioProject visualStudioProject, HostWorkspaceServices workspaceServices) : base(visualStudioProject, workspaceServices) { _visualStudioProject = visualStudioProject; }
public void StartBatch() { _batchScopes.Push(VisualStudioProject.CreateBatchScope()); }
/// <summary> /// Call for program projects (exe) when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildExeProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { return VisitBuildWebProjectTarget(project, coreOptions); }
public virtual bool IsTestProject(VisualStudioProject project) { return project.IsTestProject; }
/// <summary> /// Called when it is time to add build specific instructions for a <paramref name="project"/> that contains WCF services /// </summary> /// <param name="project">The project that will be visited for build for the specific Service target</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitServiceTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { return VisitBuildAllTypeTarget(project, coreOptions); }
/// <inheritdoc /> void IVisualStudioProjectCustomizer.WriteVisualStudioBegin(VisualStudioProject project, Platform platform, StringBuilder vcProjectFileContent, StringBuilder vcFiltersFileContent, StringBuilder vcUserFileContent) { }
/// <summary> /// Call for program projects (exe) when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitBuildExeProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { // Same logic for exe and library projects, defaults to same implementation return VisitBuildLibraryProjectTarget(project, coreOptions); }
/// <summary> /// Called when it is time to add build specific instructions for a <paramref name="project"/> that contains WCF services /// </summary> /// <param name="project">The project that will be visited for build for the specific Service target</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public override string VisitServiceTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { // Building a web service and a web project is the same return VisitBuildWebProjectTarget(project, coreOptions); }
/// <summary> /// Parses the visual studio project and return the resulting /// </summary> /// <param name="visualStudioProjectPath">Path to the Visual Studio Project to parse</param> /// <param name="result">The parsed project if supported, null otherwise</param> /// <returns> /// <c>true</c> if the parser was able to load this Visual Studio Project, <c>false</c> otherwise /// </returns> public bool TryParse(string visualStudioProjectPath, out VisualStudioProject result) { try { result = Parse(visualStudioProjectPath); return true; } catch { // Ingore the error and return false result = null; } return false; }
/// <summary> /// Call for program projects (exe) when it is time to add build information to the build file for the <paramref name="project"/>, for each possible targets /// </summary> /// <param name="project">The project that is being visited for build</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public virtual string VisitBuildExeProjectTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { return null; }
/// <summary> /// Called just after adding specific instructions for the Clean target of the <paramref name="project"/> /// </summary> /// <param name="project">The project that will be visited for build for the specific Clean target</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public virtual string PostVisitCleanTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { return null; }
internal ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, VisualStudioProject project, IVsHierarchy hierarchy, uint itemid, VisualStudioProjectTracker projectTrackerOpt, ProjectId projectId, TLanguageService languageService, IFormattingRule vbHelperFormattingRule = null) { this.BufferCoordinator = bufferCoordinator; this.ComponentModel = componentModel; this.Project = project; _languageService = languageService; this.Workspace = projectTrackerOpt?.Workspace ?? componentModel.GetService <VisualStudioWorkspace>(); _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _diagnosticAnalyzerService = componentModel.GetService <IDiagnosticAnalyzerService>(); // Get the ITextBuffer for the secondary buffer Marshal.ThrowExceptionForHR(bufferCoordinator.GetSecondaryBuffer(out var secondaryTextLines)); var secondaryVsTextBuffer = (IVsTextBuffer)secondaryTextLines; SubjectBuffer = _editorAdaptersFactoryService.GetDocumentBuffer(secondaryVsTextBuffer); // Get the ITextBuffer for the primary buffer Marshal.ThrowExceptionForHR(bufferCoordinator.GetPrimaryBuffer(out var primaryTextLines)); DataBuffer = _editorAdaptersFactoryService.GetDataBuffer((IVsTextBuffer)primaryTextLines); // Create our tagger var bufferTagAggregatorFactory = ComponentModel.GetService <IBufferTagAggregatorFactoryService>(); _bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator <ITag>(SubjectBuffer); if (!ErrorHandler.Succeeded(((IVsProject)hierarchy).GetMkDocument(itemid, out var filePath))) { // we couldn't look up the document moniker from an hierarchy for an itemid. // Since we only use this moniker as a key, we could fall back to something else, like the document name. Debug.Assert(false, "Could not get the document moniker for an item from its hierarchy."); if (!hierarchy.TryGetItemName(itemid, out filePath)) { FatalError.Report(new System.Exception("Failed to get document moniker for a contained document")); } } DocumentId documentId; if (this.Project != null) { documentId = this.Project.AddSourceTextContainer(SubjectBuffer.AsTextContainer(), filePath); } else { documentId = DocumentId.CreateNewId(projectId, $"{nameof(ContainedDocument)}: {filePath}"); // We must jam a document into an existing workspace, which we'll assume is safe to do with OnDocumentAdded Workspace.OnDocumentAdded(DocumentInfo.Create(documentId, filePath, filePath: filePath)); Workspace.OnDocumentOpened(documentId, SubjectBuffer.AsTextContainer()); } this.ContainedDocument = new ContainedDocument( componentModel.GetService <IThreadingContext>(), documentId, subjectBuffer: SubjectBuffer, dataBuffer: DataBuffer, bufferCoordinator, this.Workspace, project, hierarchy, itemid, componentModel, vbHelperFormattingRule); // TODO: Can contained documents be linked or shared? this.DataBuffer.Changed += OnDataBufferChanged; }
public VSTypeScriptVisualStudioProjectWrapper(VisualStudioProject underlyingObject) => Project = underlyingObject;
/// <summary> /// Adds the copy packages information. /// </summary> /// <param name="project">The project.</param> /// <param name="coreOptions">The core options.</param> /// <param name="uniqueOutputPath">if set to <c>true</c> [unique output path].</param> /// <param name="configuration">The configuration.</param> /// <returns></returns> private static string AddCopyPackagesInformation(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions, bool uniqueOutputPath, string configuration = "$(Configuration)") { var buildBuilder = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); string temp; string command; if (!uniqueOutputPath) { temp = string.Format("{0}\\bin\\Packages\\{1}\\{2}.zip", folder, configuration, project.AssemblyName); command = string.Format(" <Move SourceFiles=\"{0}\" DestinationFolder=\"$(DestinationFolder)\\Packages\\{1}\" Condition=\"Exists('{0}') AND $(GenerateMsDeployPackages)\" ContinueOnError=\"$(ContinueOnError)\" />", temp, configuration); } else { temp = string.Format("(UniqueOutputPath)\\Packages\\{0}\\{1}.zip", configuration, project.AssemblyName); command = string.Format(" <Move SourceFiles=\"{0}\" DestinationFolder=\"$(DestinationFolder)\\Packages\\{1}\" Condition=\"Exists('{0}') AND $(GenerateMsDeployPackages)\" ContinueOnError=\"$(ContinueOnError)\" />", temp, configuration); } buildBuilder.AppendLine(command); return buildBuilder.ToString(); }
internal BatchScope(VisualStudioProject visualStudioProject) { _project = visualStudioProject; }
void IAnalyzerHost.RemoveAdditionalFile(string additionalFilePath) => VisualStudioProject.RemoveAdditionalFile(additionalFilePath);
public void AddReferenceToCodeDirectoryEx(string assemblyFileName, ICSharpProjectRoot projectRoot, CompilerOptions optionID) { CSharpProjectShim projectSite = GetProjectSite(projectRoot); VisualStudioProject.AddProjectReference(new ProjectReference(projectSite.VisualStudioProject.Id, embedInteropTypes: optionID == CompilerOptions.OPTID_IMPORTSUSINGNOPIA)); }
void IAnalyzerConfigFileHost.RemoveAnalyzerConfigFile(string filePath) => VisualStudioProject.RemoveAnalyzerConfigFile(filePath);
/// <summary> /// Either upgrades a current config or converts an existing solution into SlugCI format /// </summary> /// <returns></returns> public bool Converter() { // Create src folder if it does not exist. if (!DirectoryExists(CISession.SourceDirectory)) { Directory.CreateDirectory(CISession.SourceDirectory.ToString()); } // Create Tests folder if it does not exist. if (!DirectoryExists(CISession.TestsDirectory)) { Directory.CreateDirectory(CISession.TestsDirectory.ToString()); } // Create Artifacts / Output folder if it does not exist. if (!DirectoryExists(CISession.OutputDirectory)) { Directory.CreateDirectory(CISession.OutputDirectory.ToString()); } // Load an existing SlugCI file if there is one. SlugCIConfig = GetSlugCIConfig(); // Load our own version of the Visual Studio project, so we can process some info from it foreach (Project project in CISession.Solution.AllProjects) { VisualStudioProject vsProject = GetInitProject(project); Projects.Add(vsProject); } // If New to SlugCI if (SlugCIConfig == null) { // Determine if any of these are a test project... If so we confirm with user and then move. foreach (VisualStudioProject visualStudioProject in Projects) { GetVisualStudioProjectInfoForNewProjectFromUser(visualStudioProject); } bool setupSuccess = SlugCI_NewSetup_EnsureProperDirectoryStructure(CISession.SolutionFileName); ControlFlow.Assert(setupSuccess, "Attempted to put solution in proper directory structure, but failed."); } else { // See if any new Projects, if so prompt for required info foreach (VisualStudioProject visualStudioProject in Projects) { SlugCIProject slugCIProject = CISession.SlugCIConfigObj.GetProjectByName(visualStudioProject.Name); if (slugCIProject == null) { GetVisualStudioProjectInfoForNewProjectFromUser(visualStudioProject); } } } // Ensure Config file is valid and up-to-date with current Class Structure ProcessSlugCIConfigFile(); return(true); }
/// <summary> /// Gets the ms deploy command. /// </summary> /// <param name="project">The project.</param> /// <param name="coreOptions">The core options.</param> /// <param name="configuration">The configuration.</param> /// <param name="isTransform">if set to <c>true</c> [is transform].</param> /// <returns></returns> private string GetMsDeployCommand(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions, string configuration = "$(Configuration)", bool isTransform = false) { var packageCommand = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); var filename = project.GetRelativeFilePath(coreOptions); var regExParamEntry = string.Format(".+\\\\{0}", Regex.Escape(folder)); string conditions ; if(isTransform) conditions = string.Format("Condition=\"$(GenerateMsDeployPackages) AND Exists('{0}\\web.{1}.config')\"", folder, configuration); else conditions = string.Format("Condition=\"$(GenerateMsDeployPackages) AND Exists('{0}\\bin')\"", folder); packageCommand.AppendLine(string.Format(" <MakeDir Directories=\"$(MSBuildProjectDirectory)\\{0}\\bin\\Packages\\{1}\\\" {2} />", folder, configuration, conditions)); string skipWebConfig = null; if (isTransform) { var assemblyNameEscaped = Regex.Escape(string.Format("{0}\\{1}", project.AssemblyName, "web.config")); skipWebConfig = string.Format("-skip:objectname=filepath,absolutepath=\"{0}\" -replace:objectName=filepath,scopeAttributeName=path,match=web.transformed.{1}.config,replace=web.config", assemblyNameEscaped, configuration); } packageCommand.AppendLine(String.Format(" <Exec Command='\"$(MsDeployLocation)\" -verb:sync -source:iisApp=\"$(MSBuildProjectDirectory)\\{0}\" -dest:package=\"$(MSBuildProjectDirectory)\\{0}\\bin\\Packages\\{1}\\{2}.zip\" -declareParam:name=\"IIS Web Application Name\",value=\"{2}\",tags=IisApp,kind=ProviderPath,scope=IisApp,match=\"{3}\" {4} -skip:objectName=filePath,absolutePath=\".*\\.vb$|pdb$\" -skip:objectName=dirPath,absolutePath=\"obj|_Resharper|Packages|_PublishedWebsites\" ' {5} />", folder, configuration, Path.GetFileNameWithoutExtension(filename), regExParamEntry, skipWebConfig, conditions)); return packageCommand.ToString(); }
void IAnalyzerHost.AddAdditionalFile(string additionalFilePath) { VisualStudioProject.AddAdditionalFile(additionalFilePath); }
void IAnalyzerHost.RemoveAnalyzerReference(string analyzerAssemblyFullPath) => VisualStudioProject.RemoveAnalyzerReference(analyzerAssemblyFullPath);
/// <summary> /// Adds the copy information. /// </summary> /// <param name="project">The project.</param> /// <param name="coreOptions">The core options.</param> /// <param name="capitalizedExt">The capitalized ext.</param> /// <param name="uniqueOutputPath">if set to <c>true</c> [unique output path].</param> /// <returns></returns> private string AddCopyInformation(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions, string capitalizedExt, bool uniqueOutputPath) { var buildBuilder = new StringBuilder(); var folder = project.GetRelativeFolderPath(coreOptions); if (!uniqueOutputPath) { // In a non web project, we look in the configuration folder, otherwise in the bin folder string temp; if (!project.IsWebProject) temp = string.Format("{0}\\bin\\$(Configuration)\\{1}.{2}", folder, project.AssemblyName, capitalizedExt.ToLower()); else temp = string.Format("{0}\\bin\\{1}.{2}", folder, project.AssemblyName, capitalizedExt.ToLower()); buildBuilder.AppendFormat(" <Copy SourceFiles=\"{0}\" DestinationFolder=\"$(DestinationFolder)\" Condition=\"Exists('{0}') AND $(CopyEnabled) AND $(Copy{1})\" ContinueOnError=\"$(ContinueOnError)\" OverwriteReadOnlyFiles=\"True\" SkipUnchangedFiles=\"True\" />", temp, capitalizedExt); buildBuilder.AppendLine(); if (_options.CopyCodeContracts) { if (!project.IsWebProject) temp = string.Format("{0}\\bin\\$(Configuration)\\CodeContracts\\{1}.Contracts.{2}", folder, project.AssemblyName, capitalizedExt.ToLower()); else temp = string.Format("{0}\\bin\\CodeContracts\\{1}.Contracts.{2}", folder, project.AssemblyName, capitalizedExt.ToLower()); buildBuilder.AppendFormat(" <Copy SourceFiles=\"{0}\" DestinationFolder=\"$(DestinationFolder)\\CodeContracts\" Condition=\"Exists('{0}') AND $(CopyEnabled) AND $(Copy{1}) AND $(CopyCodeContracts)\" ContinueOnError=\"$(ContinueOnError)\" OverwriteReadOnlyFiles=\"True\" SkipUnchangedFiles=\"True\" />", temp, capitalizedExt); } buildBuilder.AppendLine(); } return buildBuilder.ToString(); }
/// <summary> /// Prompts the user for the type of deployment the given project should use. /// </summary> /// <param name="projectName"></param> /// <returns></returns> private SlugCIDeployMethod PromptUserForDeployMethod(VisualStudioProject project) { Console.WriteLine(); Console.WriteLine(); AOT_Info("Project - [" + project.Name + "] has been added to the SlugCI config file."); // Determine Deploy Method string deployMethod = ""; if (project.ProjectType == "Library") { deployMethod = "Nuget"; } else if (project.ProjectType == "Exe") { if (project.IsToolPackage) { deployMethod = "Tool"; } else { deployMethod = "Copy"; } } else { deployMethod = "None"; } AOT_Normal("It appears the deployment method for this project would be " + deployMethod + ". Press enter to accept this default or select letter.", Color.Yellow); //"What deployment method does this project use?", Color.Yellow); bool continuePrompting = true; while (continuePrompting) { Console.WriteLine("Press: "); Console.WriteLine(" (N) For Nuget Deploy"); Console.WriteLine(" (C) For File Copy Deploy"); Console.WriteLine(" (T) for Tool Deploy"); Console.WriteLine(" (0) For Not Specified"); while (Console.KeyAvailable) { Console.ReadKey(false); } ConsoleKeyInfo inputKey = Console.ReadKey(); if (inputKey.Key == ConsoleKey.Enter) { if (deployMethod == "Nuget") { return(SlugCIDeployMethod.Nuget); } else if (deployMethod == "Copy") { return(SlugCIDeployMethod.Copy); } else if (deployMethod == "Tool") { return(SlugCIDeployMethod.Tool); } else { return(SlugCIDeployMethod.None); } } if (inputKey.Key == ConsoleKey.N) { return(SlugCIDeployMethod.Nuget); } if (inputKey.Key == ConsoleKey.C) { return(SlugCIDeployMethod.Copy); } if (inputKey.Key == ConsoleKey.T) { return(SlugCIDeployMethod.Tool); } if (inputKey.Key == ConsoleKey.D0) { return(SlugCIDeployMethod.None); } } return(SlugCIDeployMethod.None); }
void IAnalyzerHost.AddAnalyzerReference(string analyzerAssemblyFullPath) { VisualStudioProject.AddAnalyzerReference(analyzerAssemblyFullPath); }
public void OnImportRemoved(string filename, string project) { filename = FileUtilities.NormalizeAbsolutePath(filename); VisualStudioProject.RemoveMetadataReference(filename, VisualStudioProject.GetPropertiesForMetadataReference(filename).Single()); }
public void SetUp() { File.Copy(projectLocation, tempProjectLocation, true); cSharpProject = new CSharpProject(tempProjectLocation); }
/// <summary> /// Called just before adding specific instructions for a <paramref name="project"/> that contains WCF services /// </summary> /// <param name="project">The project that will be visited for build for the specific Service target</param> /// <param name="coreOptions">The application core options</param> /// <returns> /// The msbuild syntax to add to the build file /// </returns> public virtual string PreVisitServiceTarget(VisualStudioProject project, IMsBuilderificCoreOptions coreOptions) { return null; }