/// <summary>
        /// Converts a non-vsix guidance package project file into vsix by adding
        /// some properties and imports.
        /// </summary>
        public override void Execute()
        {
            TraceUtil.TraceInformation(this, "Updating guidance package project file to VSIX...");

            this.PackageProject.Save();

            var tempPath = Path.GetTempFileName();

            File.Copy(this.PackageProject.FullName, tempPath, true);

            var project = new Build.Evaluation.Project(tempPath);

            TraceUtil.TraceInformation(this, "\tSetting VSIX properties...");
            // Add properties
            AddProperty(project, "GeneratePkgDefFile", "false");
            AddProperty(project, "IncludeAssemblyInVSIXContainer", "true");
            AddProperty(project, "IncludeDebugSymbolsInVSIXContainer", "false");
            AddProperty(project, "IncludeDebugSymbolsInLocalVSIXDeployment", "true");
            AddProperty(project, "CopyBuildOutputToOutputDirectory", "true");
            AddProperty(project, "CopyOutputSymbolsToOutputDirectory", "true");
            AddProperty(project, "ProjectTypeGuids", "{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");
            AddProperty(project, "TargetFrameworkVersion", "v4.0");

            // Add imports
            TraceUtil.TraceInformation(this, "\tAdding VS SDK targets...");
            AddImport(project, @"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v14.0\VSSDK\Microsoft.VsSDK.targets");
            TraceUtil.TraceInformation(this, "\tAdding GAX targets...");
            AddImport(project, @"$(RecipeFrameworkPath)\Microsoft.Practices.RecipeFramework.Build.targets");

            project.Save();

            File.WriteAllText(this.PackageProject.FullName, File.ReadAllText(tempPath));
        }
Example #2
0
        /// <summary>
        /// Gets the msbuild item
        /// </summary>
        /// <param name="includeSpec"></param>
        /// <returns></returns>
        public Build.Evaluation.ProjectItem GetBuildItem(string includeSpec)
        {
            Guard.ArgumentNotNullOrEmptyString(includeSpec, "includeSpec");

            string currentDir = "." + System.IO.Path.DirectorySeparatorChar;

            if (includeSpec.StartsWith(currentDir, StringComparison.OrdinalIgnoreCase))
            {
                includeSpec = includeSpec.Substring(currentDir.Length);
            }

            Build.Evaluation.Project msbuildProject = MSBuildProject;
            foreach (Build.Evaluation.ProjectItem item in msbuildProject.Items)
            {
                if (item.EvaluatedInclude.Equals(includeSpec, StringComparison.OrdinalIgnoreCase))
                {
                    return(item);
                }
            }

            return(null);
        }