Example #1
0
        private ISiteBuilder DetermineProject(string repositoryRoot, string targetPath, IDeploymentSettingsManager perDeploymentSettings, IFileFinder fileFinder)
        {
            if (!DeploymentHelper.IsDeployableProject(targetPath))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  Resources.Error_ProjectNotDeployable,
                                                                  targetPath));
            }
            else if (File.Exists(targetPath))
            {
                var    solution     = VsHelper.FindContainingSolution(targetPath, fileFinder);
                string solutionPath = solution != null ? solution.Path : null;

                return(new WapBuilder(_environment,
                                      perDeploymentSettings,
                                      _propertyProvider,
                                      repositoryRoot,
                                      targetPath,
                                      solutionPath));
            }

            throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                              Resources.Error_ProjectDoesNotExist,
                                                              targetPath));
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="T:CustomTypeProvider"/> class.
            /// </summary>
            /// <param name="provider">The provider.</param>
            public CustomTypeProvider(IServiceProvider provider)
            {
                DynamicTypeService typeService = (DynamicTypeService)provider.GetService(typeof(DynamicTypeService));

                System.Diagnostics.Debug.Assert(typeService != null, "No dynamic type service registered.");

                IVsHierarchy hier = DteHelper2.GetCurrentSelection(provider);

                System.Diagnostics.Debug.Assert(hier != null, "No active hierarchy is selected.");

                ITypeDiscoveryService discovery = typeService.GetTypeDiscoveryService(hier);
                Project dteProject = VsHelper.ToDteProject(hier);

                availableTypes = new Dictionary <string, Type>();
                LoadTypes(availableTypes, discovery.GetTypes(typeof(object), false), dteProject);

                // Try loading Project references
                LoadProjectReferenceTypesFromCurrentProject(availableTypes, provider, dteProject);

                // If we don't get any type loaded, try with the rest of the projects in the current sln
                if (availableTypes.Count == 0)
                {
                    LoadTypesFromSolution(availableTypes, provider, dteProject);
                }

                EnsureKnownTypes(availableTypes);

                if (availableTypes.Count > 0 && TypesChanged != null)
                {
                    TypesChanged(this, new EventArgs());
                }
            }
Example #3
0
        public void ScmHostingConfigurationsEnabledByDefault()
        {
            // enabled / disabled by default
            Assert.True(VsHelper.UseMSBuild16(), "SCM_USE_MSBUILD_16");
            Assert.True(ScmHostingConfigurations.GetLatestDeploymentOptimized, "GetLatestDeploymentOptimized");
            Assert.True(ScmHostingConfigurations.DeploymentStatusCompleteFileEnabled, "DeploymentStatusCompleteFileEnabled");
            Assert.False(VsHelper.UseMSBuild1607(), "SCM_USE_MSBUILD_1607");

            ScmHostingConfigurations.Config = new Dictionary <string, string>
            {
                { "SCM_USE_MSBUILD_16", "0" },
                { "GetLatestDeploymentOptimized", "0" },
                { "DeploymentStatusCompleteFileEnabled", "0" },
                { "SCM_USE_MSBUILD_1607", "1" }
            };
            try
            {
                Assert.False(VsHelper.UseMSBuild16(), "SCM_USE_MSBUILD_16");
                Assert.False(ScmHostingConfigurations.GetLatestDeploymentOptimized, "GetLatestDeploymentOptimized");
                Assert.False(ScmHostingConfigurations.DeploymentStatusCompleteFileEnabled, "DeploymentStatusCompleteFileEnabled");
                Assert.True(VsHelper.UseMSBuild1607(), "SCM_USE_MSBUILD_1607");
            }
            finally
            {
                ScmHostingConfigurations.Config = null;
            }
        }
Example #4
0
        // used when we have a project file
        private ISiteBuilder DetermineProject(string repositoryRoot, string targetPath, IDeploymentSettingsManager perDeploymentSettings, IFileFinder fileFinder)
        {
            var    solution         = VsHelper.FindContainingSolution(repositoryRoot, targetPath, fileFinder);
            string solutionPath     = solution?.Path;
            var    projectTypeGuids = VsHelper.GetProjectTypeGuids(targetPath);

            if (VsHelper.IsWap(projectTypeGuids))
            {
                return(new WapBuilder(_environment,
                                      perDeploymentSettings,
                                      _propertyProvider,
                                      repositoryRoot,
                                      targetPath,
                                      solutionPath));
            }
            else if (AspNetCoreHelper.IsDotnetCoreFromProjectFile(targetPath, projectTypeGuids))
            {
                return(new AspNetCoreBuilder(_environment,
                                             perDeploymentSettings,
                                             _propertyProvider,
                                             repositoryRoot,
                                             targetPath,
                                             solutionPath));
            }
            else if (VsHelper.IsExecutableProject(targetPath))
            {
                // This is a console app
                return(new DotNetConsoleBuilder(_environment,
                                                perDeploymentSettings,
                                                _propertyProvider,
                                                repositoryRoot,
                                                targetPath,
                                                solutionPath));
            }
            else if (FunctionAppHelper.LooksLikeFunctionApp())
            {
                if (FunctionAppHelper.IsCSharpFunctionFromProjectFile(targetPath))
                {
                    return(new FunctionMsbuildBuilder(_environment,
                                                      perDeploymentSettings,
                                                      _propertyProvider,
                                                      repositoryRoot,
                                                      targetPath,
                                                      solutionPath));
                }
                else
                {
                    // csx or node function with extensions.csproj
                    return(new FunctionBasicBuilder(_environment,
                                                    perDeploymentSettings,
                                                    _propertyProvider,
                                                    repositoryRoot,
                                                    Path.GetDirectoryName(targetPath)));
                }
            }

            throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                              Resources.Error_ProjectNotDeployable,
                                                              targetPath));
        }
        public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            var vs = automationObject as EnvDTE.DTE;

            if (vs != null)
            {
                using (var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)vs))
                {
                    tracer.ShieldUI((Action)(() =>
                    {
                        var shell = serviceProvider.GetService <SVsShell, IVsShell>();

                        var registryRoot = VsHelper.GetPropertyOrDefault <string>(shell.GetProperty, (int)__VSSPROPID.VSSPROPID_VirtualRegistryRoot);
                        var suffix = registryRoot.Replace(VsSettingsRegistryKey, string.Empty);

                        replacementsDictionary.Add(@"$vsrootsuffix$", suffix);

                        tracer.Info(Resources.VsRootSuffixTemplateWizard_RootSuffixDetermined, suffix);
                    }),
                                    Resources.VsRootSuffixTemplateWizard_FailedToRetrieveRegistryRoot);
                }
            }
        }
Example #6
0
        private bool VerifyDslVersion(string storeFile)
        {
            bool isValidVersion = true;

            var exception =
                tracer.Shield(
                    () =>
            {
                var document   = XDocument.Load(storeFile);
                var dslVersion = new Version(document.Root.Attribute(DslVersionAttribute).Value);

                if (dslVersion != StoreConstants.DslVersion)
                {
                    if (this.messageService.PromptWarning(
                            string.Format(CultureInfo.InvariantCulture,
                                          Properties.Resources.PatternManager_NewerDslVersionUpgrade, Path.GetFileName(this.StoreFile), StoreConstants.ProductName)))
                    {
                        document.Root.Attribute(DslVersionAttribute).Value = StoreConstants.DslVersion.ToString();

                        VsHelper.CheckOut(storeFile);

                        document.Save(storeFile);
                    }
                    else
                    {
                        isValidVersion = false;
                    }
                }
            }, Properties.Resources.PatternManager_FailedToVerifyDslVersion);

            return(isValidVersion && exception == null);
        }
Example #7
0
        /// <summary>
        /// Configures the files included in the template for VSIX packaging,
        /// and returns the Uri for the template.
        /// </summary>
        public IVsTemplate Configure(IItem templateItem, string displayName, string description, string path)
        {
            Guard.NotNull(() => templateItem, templateItem);

            // Calculate the new Identifier
            var unicySeed            = Guid.NewGuid().ToString(@"N");
            var unicyIdentifier      = unicySeed.Substring(unicySeed.Length - MaxUnicyLength);
            var remainingNamedLength = MaxTemplateIdLength - MaxUnicyLength - 1;
            var namedIdentifier      = path.Substring(path.Length <= remainingNamedLength ? 0 : (path.Length - remainingNamedLength));
            var templateId           = string.Format(CultureInfo.InvariantCulture, @"{0}-{1}", unicyIdentifier, namedIdentifier);

            // Update the vstemplate
            var template = VsTemplateFile.Read(templateItem.PhysicalPath);

            template.SetTemplateId(templateId);
            template.SetDefaultName(SanitizeName(displayName));
            template.SetName(displayName);
            template.SetDescription(description);
            VsHelper.CheckOut(template.PhysicalPath);
            VsTemplateFile.Write(template);

            UpdateDirectoryProperties(templateItem);

            // Set VS attributes on the vstemplate file
            if (template.Type == VsTemplateType.Item)
            {
                templateItem.Data.ItemType = @"ItemTemplate";
            }
            else
            {
                templateItem.Data.ItemType = @"ProjectTemplate";
            }

            return(template);
        }
Example #8
0
        public void GetTargetFrameworks(string targetFrameworks, string expected)
        {
            // Arrange
            var CsprojFileContent = string.Format(
                @"<Project Sdk=""Microsoft.NET.Sdk"">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>{0}</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <Content Include=""run.bat"">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>
", targetFrameworks);

            // Act
            var result = VsHelper.GetTargetFrameworkContents(CsprojFileContent);

            // Assert
            Assert.Equal(expected, result);
        }
Example #9
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var question = MessageBox.Show("Selecting this command will install a NuGet package that will enable this project for script generation. " +
                                           "\r\rDo you want to continue?", "Install NuGet Package?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (question == DialogResult.No)
            {
                return;
            }

            foreach (Project proj in VsHelper.GetSelectedCsharpProjects())
            {
                if (!VsHelper.IsPackageInstalled(proj))
                {
                    try
                    {
                        IComponentModel     componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
                        IVsPackageInstaller installer      = componentModel.GetService <IVsPackageInstaller>();
                        installer.InstallPackage(null, proj, TypeRightPackage.NugetID, (string)null, false);
                    }
                    catch (Exception exception)
                    {
                        // Show a message box to prove we were here
                        VsShellUtilities.ShowMessageBox(
                            this.ServiceProvider,
                            "There was an error installing the package: \n\n" + exception.Message,
                            "Could not install package",
                            OLEMSGICON.OLEMSGICON_CRITICAL,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// Determines whether this command is visible
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = false;
            button.Visible = false;

            var selProjs = VsHelper.GetSelectedCsharpProjects();

            if (!selProjs.Any())
            {
                return;
            }

            button.Visible = true;

            foreach (Project proj in selProjs)
            {
                if (!VsHelper.IsPackageInstalled(proj))
                {
                    button.Enabled = true;
                }
            }
        }
Example #11
0
        /// <summary>
        /// Loads the Blackboard from the global XML file
        /// </summary>
        /// <returns>A &lt;string,string&gt; dictionary deserialized from the file</returns>
        private Dictionary <string, string> GetBlackboardDataFromFile()
        {
            Dictionary <string, string> result;

            if (!IsPersistent)
            {
                return(this.blackboard);
            }

            //
            // Check it out if it's under source control
            //
            VsHelper.CheckOut(blackboardFileName);

            if (!File.Exists(this.blackboardFileName))
            {
                this.blackboard = new Dictionary <string, string>();
                this.WriteBlackboardDataToFile();
            }

            using (XmlReader reader = XmlReader.Create(this.blackboardFileName))
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary <string, string>));

                result = (Dictionary <string, string>)serializer.ReadObject(reader);
            }

            return(result);
        }
        public void IsDotNetCore3DetectsDotNetCore2_2()
        {
            // Arrange
            var CsprojFileContent =
                @"<Project Sdk=""Microsoft.NET.Sdk"">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  
  <ItemGroup>
    <Content Include=""run.bat"">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>
";

            // Act
            var result = VsHelper.IsDotNetCore3CsProj(CsprojFileContent);

            // Assert
            Assert.Equal(result, false);
        }
Example #13
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            Workspace currentWorkspace = VsHelper.Current.GetCurrentWorkspace();

            foreach (EnvDTE.Project proj in VsHelper.GetSelectedItemsOfType <EnvDTE.Project>())
            {
                if (ConfigProcessing.IsGenEnabledForProject(proj))
                {
                    IScriptGenEngineProvider <Workspace> provider = Imports.ScriptGenAssemblyCache.GetForProj(proj).EngineProvider;
                    IScriptGenEngine        engine = provider.GetEngine(currentWorkspace, proj.FullName);
                    IScriptGenerationResult result = engine.GenerateScripts();
                    // Show a message box to prove we were here
                    if (!result.Sucess)
                    {
                        VsShellUtilities.ShowMessageBox(
                            this.ServiceProvider,
                            result.ErrorMessage,
                            "Script Generation Failed",
                            OLEMSGICON.OLEMSGICON_CRITICAL,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            foreach (Project proj in VsHelper.GetSelectedCsharpProjects())
            {
                if (!ConfigProcessing.ConfigExistsForProject(proj))
                {
                    string configPath = ScriptGenAssemblyCache.GetForProj(proj)?.GetConfigFilepath(proj.FullName);
                    if (string.IsNullOrEmpty(configPath))
                    {
                        VsShellUtilities.ShowMessageBox(
                            ServiceProvider,
                            "Failed to find target configuration file path.  It is possible you need to update the Nuget Package.",
                            "Add Config Failed",
                            OLEMSGICON.OLEMSGICON_CRITICAL,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                        return;
                    }


                    if (!File.Exists(configPath))
                    {
                        ScriptGenAssemblyCache.GetForProj(proj).CreateNewConfigFile(configPath);
                    }
                    proj.ProjectItems.AddFromFile(configPath);
                }
            }
        }
Example #15
0
        public void GetTargetFramework_DotNetFramework()
        {
            // Arrange
            var CsprojFileContent =
                @"<Project Sdk=""Microsoft.NET.Sdk.Web"">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <DebugType>full</DebugType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include=""Microsoft.AspNetCore"" Version=""2.2.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.CookiePolicy"" Version=""2.2.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.HttpsPolicy"" Version=""2.2.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Mvc"" Version=""2.2.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.StaticFiles"" Version=""2.2.0"" />
  </ItemGroup>

</Project>
";

            // Act
            var result = VsHelper.GetTargetFrameworkContents(CsprojFileContent);

            // Assert
            Assert.Equal(result, "net472");
        }
        private Type GetProxyType(ITypeDescriptorContext context)
        {
            IDictionaryService dictionary = VsHelper.GetService <IDictionaryService>(context, true);
            Type proxyType = (Type)dictionary.GetValue(ProxyArgumentName);

            return(proxyType);
        }
        private List <MethodInfo> GetMethodsList(ITypeDescriptorContext context)
        {
            IDictionaryService dictionary  = VsHelper.GetService <IDictionaryService>(context, true);
            List <MethodInfo>  methodsList = (List <MethodInfo>)dictionary.GetValue(MethodsArgumentName);

            return(methodsList);
        }
Example #18
0
        public void SniffGlobalJson(string globalJsonContent, string expected)
        {
            // Act
            var result = VsHelper.SniffGlobalJsonContents(globalJsonContent);

            // Assert
            Assert.Equal(expected, result);
        }
Example #19
0
 public VsErcPackage()
 {
     instance = this;
     this.vsHelper = new VsHelper(this);
     this.vsErcLogger = new VsErcLogger(this);
     this.lua = new Lua();
     this.vsErcBindings = new VsErcBindings(this, VsErcBindings.DefaultErcFilePath);
 }
Example #20
0
 public VsEvents(VsHelper vsHelper)
 {
     this.vsHelper = vsHelper;
     this.documentListener = new DocumentListener(this);
     this.solutionListener = new SolutionListener(this);
     this.projectDocumentListener = new ProjectDocumensListener(this);
     this.projectRetargettingListener = new ProjectRetargettingListener(this);
 }
Example #21
0
        private ISiteBuilder ResolveProject(string repositoryRoot, string targetPath, IDeploymentSettingsManager perDeploymentSettings, IFileFinder fileFinder, bool tryWebSiteProject, SearchOption searchOption = SearchOption.AllDirectories, bool specificConfiguration = true)
        {
            if (DeploymentHelper.IsProject(targetPath))
            {
                return(DetermineProject(repositoryRoot, targetPath, perDeploymentSettings, fileFinder));
            }

            // Check for loose projects
            var projects = DeploymentHelper.GetProjects(targetPath, fileFinder, searchOption);

            if (projects.Count > 1)
            {
                // Can't determine which project to build
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  Resources.Error_AmbiguousProjects,
                                                                  String.Join(", ", projects)));
            }
            else if (projects.Count == 1)
            {
                return(DetermineProject(repositoryRoot, projects[0], perDeploymentSettings, fileFinder));
            }

            if (tryWebSiteProject)
            {
                // Website projects need a solution to build so look for one in the repository path
                // that has this website in it.
                var solutions = VsHelper.FindContainingSolutions(targetPath, fileFinder);

                // More than one solution is ambiguous
                if (solutions.Count > 1)
                {
                    ThrowAmbiguousSolutionsError(solutions);
                }
                else if (solutions.Count == 1)
                {
                    // Unambiguously pick the root
                    return(new WebSiteBuilder(_environment,
                                              perDeploymentSettings,
                                              _propertyProvider,
                                              repositoryRoot,
                                              targetPath,
                                              solutions[0].Path));
                }
            }

            // This should only ever happen if the user specifies an invalid directory.
            // The other case where the method is called we always resolve the path so it's a non issue there.
            if (specificConfiguration && !Directory.Exists(targetPath))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  Resources.Error_ProjectDoesNotExist,
                                                                  targetPath));
            }

            // If there's none then use the basic builder (the site is xcopy deployable)
            return(ResolveNonAspProject(repositoryRoot, targetPath, perDeploymentSettings));
        }
Example #22
0
 public CompositeClassGenerator(
     BaseCustomTool customTool, ICodeGenerator codeGenerator, string inputFileName)
 {
     _codeGenerator = codeGenerator;
     _inputFileName = inputFileName;
     _vsHelper      = new VsHelper();
     EnvDTE.Project project = _vsHelper.GetProject();
     _assemblies       = _vsHelper.GetReferencedAssemblies(customTool, false);
     _projectDirectory = _vsHelper.GetProjectDirectory();
 }
Example #23
0
        public void ShowPreview(IVsHierarchy hierarchy, uint itemID, string fileName)
        {
            if (FileExtensionUtility.IsInspectableFile(_optionsService, fileName))
            {
                ContentPreviewToolWindow window = ShowPreviewInternal();

                XnaBuildProperties buildProperties = VsHelper.GetXnaBuildProperties(hierarchy, itemID);
                window.LoadFile(fileName, buildProperties);
            }
        }
Example #24
0
        private void DeleteViewDiagram(IItemContainer parentItem, IViewSchema viewSchema)
        {
            var path      = GetDiagramFileName(parentItem, viewSchema);
            var childItem = parentItem.Items.FirstOrDefault(i => i.PhysicalPath == path);

            if (childItem != null)
            {
                VsHelper.CheckOut(childItem.PhysicalPath);
                childItem.As <EnvDTE.ProjectItem>().Remove();
            }
        }
 /// <summary>
 /// This function is the callback used to execute the command when the menu item is clicked.
 /// See the constructor to see how the menu item is associated with this function using
 /// OleMenuCommandService service and MenuCommand class.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event args.</param>
 private void MenuItemCallback(object sender, EventArgs e)
 {
     foreach (Project proj in VsHelper.GetSelectedItemsOfType <Project>())
     {
         if (!VsHelper.IsSolutionItemsFolder(proj) &&
             !ConfigProcessing.ConfigExistsForProject(proj))
         {
             ConfigProcessing.CreateForProject(proj);
         }
     }
 }
        private ProjectItem GetSelectedItem()
        {
            var selItems = VsHelper.GetSelectedItemsOfType <ProjectItem>().ToList();

            if (selItems.Count != 1)
            {
                return(null);
            }

            return(selItems.First());
        }
Example #27
0
        private static void SaveDocument(XDocument document, string filePath)
        {
            var serviceProvider = ServiceProvider.GlobalProvider;

            tracer.Info(ShellResources.SchemaUpgradeContext_TraceSaveSchemaFile, filePath);

            // Save file content
            VsHelper.CheckOut(filePath);
            VsHelper.WithoutFileChangeNotification(serviceProvider, filePath, () =>
            {
                document.Save(filePath);
            });
        }
Example #28
0
        public Project GetProject()
        {
            var solutions = VsHelper.GetSolutions(_root);

            return(new Project
            {
                ProjectFiles = (from s in solutions
                                from p in s.Projects
                                where p.IsWap || p.IsWebSite
                                select MakeRelative(p.AbsolutePath)).ToList(),
                Files = GetFiles().ToList(),
                SolutionFiles = solutions.Select(s => MakeRelative(s.Path)).ToList()
            });
        }
Example #29
0
        public void GetTargetFrameworkJson(string targetFramework, string expected)
        {
            // Arrange
            var jsonFileContent = string.Format(
                @"{{
  ""frameworks"":
    {{""{0}"": {{}}}}
  }}", targetFramework);

            // Act
            var result = VsHelper.GetTargetFrameworkJsonContents(jsonFileContent);

            // Assert
            Assert.Equal(expected, result);
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            VsHelper.Initialize(this);
            ScriptGenAssemblyCache.TryClearCache();

            _buildEvents = VsHelper.Current.Dte.Events.BuildEvents;
            _buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
            _buildEvents.OnBuildDone  += BuildEvents_OnBuildDone;
            AddConfigCommand.Initialize(this);
            GenerateScriptsCommand.Initialize(this);
            InstallNugetPackageCommand.Initialize(this);
            ClearCacheCommand.Initialize(this);
            base.Initialize();
        }
Example #31
0
        /// <summary>
        /// Determines whether this command is visible
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = false;

            foreach (EnvDTE.Project proj in VsHelper.GetSelectedItemsOfType <EnvDTE.Project>())
            {
                if (!VsHelper.IsSolutionItemsFolder(proj) &&
                    VsHelper.IsPackageInstalled(proj) &&
                    ConfigProcessing.IsGenEnabledForProject(proj))
                {
                    button.Enabled = true;
                }
            }
        }
Example #32
0
        /// <summary>
        /// Before query for Adding a config file to the solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Visible = false;
            button.Enabled = false;

            foreach (Project proj in VsHelper.GetSelectedCsharpProjects())
            {
                button.Visible = true;                  // At least one project is selected...
                if (!ConfigProcessing.ConfigExistsForProject(proj) && VsHelper.IsPackageInstalled(proj))
                {
                    button.Enabled = true;
                }
            }
        }
Example #33
0
 public VsCommands(VsHelper vsHelper)
 {
     this.vsHelper = vsHelper;
 }