diff --git a/build/Versions.props b/build/Versions.props index fded8ee6..ee62248c 100644 --- a/build/Versions.props +++ b/build/Versions.props @@ -28,7 +28,6 @@ 1.1.36 1.0.31 1.0.21 - diff --git a/src/Templates/VS2017/ProjectTemplates/CSharp/CodeRefactoring/Ref/CodeRefactoring.csproj b/src/Templates/VS2017/ProjectTemplates/CSharp/CodeRefactoring/Ref/CodeRefactoring.csproj index 77c43b9f..2d8e1e60 100644 --- a/src/Templates/VS2017/ProjectTemplates/CSharp/CodeRefactoring/Ref/CodeRefactoring.csproj +++ b/src/Templates/VS2017/ProjectTemplates/CSharp/CodeRefactoring/Ref/CodeRefactoring.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/CSharpConsoleApplication.vstemplate b/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/CSharpConsoleApplication.vstemplate index 6923dc1d..ff250723 100644 --- a/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/CSharpConsoleApplication.vstemplate +++ b/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/CSharpConsoleApplication.vstemplate @@ -21,4 +21,8 @@ Program.cs + + Roslyn.SDK.Template.Wizard, Version=$(AssemblyVersion), Culture=neutral, PublicKeyToken=31bf3856ad364e35 + RoslynSDKAnalyzerTemplateWizard + \ No newline at end of file diff --git a/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/ConsoleApplication.csproj b/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/ConsoleApplication.csproj index 75efb977..79924ae3 100644 --- a/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/ConsoleApplication.csproj +++ b/src/Templates/VS2017/ProjectTemplates/CSharp/ConsoleApplication/ConsoleApplication.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj b/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj index c8466a10..26e1890b 100644 --- a/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj +++ b/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj b/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj index c530b854..e44c6e63 100644 --- a/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj +++ b/src/Templates/VS2017/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/Templates/VS2017/ProjectTemplates/VisualBasic/CodeRefactoring/Ref/CodeRefactoring.vbproj b/src/Templates/VS2017/ProjectTemplates/VisualBasic/CodeRefactoring/Ref/CodeRefactoring.vbproj index 7371999e..42587ae0 100644 --- a/src/Templates/VS2017/ProjectTemplates/VisualBasic/CodeRefactoring/Ref/CodeRefactoring.vbproj +++ b/src/Templates/VS2017/ProjectTemplates/VisualBasic/CodeRefactoring/Ref/CodeRefactoring.vbproj @@ -6,7 +6,7 @@ - + diff --git a/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/ConsoleApplication.vbproj b/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/ConsoleApplication.vbproj index ae45db30..fcc01c4c 100644 --- a/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/ConsoleApplication.vbproj +++ b/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/ConsoleApplication.vbproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/VBConsoleApplication.vstemplate b/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/VBConsoleApplication.vstemplate index 862efc4f..f8275d55 100644 --- a/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/VBConsoleApplication.vstemplate +++ b/src/Templates/VS2017/ProjectTemplates/VisualBasic/ConsoleApplication/VBConsoleApplication.vstemplate @@ -21,4 +21,8 @@ Module1.vb + + Roslyn.SDK.Template.Wizard, Version=$(AssemblyVersion), Culture=neutral, PublicKeyToken=31bf3856ad364e35 + RoslynSDKAnalyzerTemplateWizard + diff --git a/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj b/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj index d956e952..537df32c 100644 --- a/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj +++ b/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj @@ -24,7 +24,7 @@ - + diff --git a/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj b/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj index 0a0448f8..172c104a 100644 --- a/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj +++ b/src/Templates/VS2017/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj @@ -6,7 +6,7 @@ - + diff --git a/src/Templates/VS2017/Roslyn.SDK.VS2017.csproj b/src/Templates/VS2017/Roslyn.SDK.VS2017.csproj index a0c5149a..b4dd31e7 100644 --- a/src/Templates/VS2017/Roslyn.SDK.VS2017.csproj +++ b/src/Templates/VS2017/Roslyn.SDK.VS2017.csproj @@ -114,6 +114,7 @@ true + diff --git a/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKChildTemplateWizard.InterfaceMembers.cs b/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKChildTemplateWizard.InterfaceMembers.cs index 9e854b10..6215b777 100644 --- a/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKChildTemplateWizard.InterfaceMembers.cs +++ b/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKChildTemplateWizard.InterfaceMembers.cs @@ -2,7 +2,10 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Linq; using System.Reflection; +using System.Xml.Linq; using EnvDTE; using Microsoft.VisualStudio.TemplateWizard; @@ -31,7 +34,25 @@ public partial class RoslynSDKChildTemplateWizard : IWizard public void ProjectItemFinishedGenerating(ProjectItem projectItem) => NugetWizard.ProjectItemFinishedGenerating(projectItem); public void RunStarted(object automationObject, Dictionary replacementsDictionary, WizardRunKind runKind, object[] customParams) { + WriteOutBetaNugetSource("dotnet.myget.org roslyn", "https://dotnet.myget.org/F/roslyn/api/v3/index.json"); NugetWizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); OnRunStarted(automationObject as DTE, replacementsDictionary, runKind, customParams); } + + private void WriteOutBetaNugetSource(string key, string value) + { + var appDataFolder = Environment.GetEnvironmentVariable("APPDATA"); + var nugetConfigPath = Path.Combine(appDataFolder, @"NuGet\NuGet.Config"); + var document = XDocument.Load(nugetConfigPath); + var packageSources = document.Root.Descendants().Where(x => x.Name.LocalName == "packageSources"); + var sources = packageSources.Elements(XName.Get("add")); + if (!sources.Where(x => x.Attribute(XName.Get("value")).Value == "https://dotnet.myget.org/F/roslyn/api/v3/index.json").Any()) + { + var newSource = new XElement(XName.Get("add")); + newSource.SetAttributeValue(XName.Get("key"), key); + newSource.SetAttributeValue(XName.Get("value"), value); + sources.Last().AddAfterSelf(newSource); + document.Save(nugetConfigPath); + } + } } diff --git a/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKRootTemplateWizard.InterfaceMembers.cs b/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKRootTemplateWizard.InterfaceMembers.cs index 15bcfcc0..4d9197ee 100644 --- a/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKRootTemplateWizard.InterfaceMembers.cs +++ b/src/Tools/Roslyn.SDK.Template.Wizard/RoslynSDKRootTemplateWizard.InterfaceMembers.cs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; using EnvDTE; using Microsoft.VisualStudio.TemplateWizard; @@ -12,5 +16,25 @@ public partial class RoslynSDKRootTemplateWizard : IWizard public bool ShouldAddProjectItem(string filePath) => true; public void ProjectItemFinishedGenerating(ProjectItem projectItem) { } public void RunStarted(object automationObject, Dictionary replacementsDictionary, WizardRunKind runKind, object[] customParams) - => OnRunStarted(automationObject as DTE, replacementsDictionary, runKind, customParams); + { + WriteOutBetaNugetSource("dotnet.myget.org roslyn", "https://dotnet.myget.org/F/roslyn/api/v3/index.json"); + OnRunStarted(automationObject as DTE, replacementsDictionary, runKind, customParams); + } + + private void WriteOutBetaNugetSource(string key, string value) + { + var appDataFolder = Environment.GetEnvironmentVariable("APPDATA"); + var nugetConfigPath = Path.Combine(appDataFolder, @"NuGet\NuGet.Config"); + var document = XDocument.Load(nugetConfigPath); + var packageSources = document.Root.Descendants().Where(x => x.Name.LocalName == "packageSources"); + var sources = packageSources.Elements(XName.Get("add")); + if (!sources.Where(x => x.Attribute(XName.Get("value")).Value == "https://dotnet.myget.org/F/roslyn/api/v3/index.json").Any()) + { + var newSource = new XElement(XName.Get("add")); + newSource.SetAttributeValue(XName.Get("key"), key); + newSource.SetAttributeValue(XName.Get("value"), value); + sources.Last().AddAfterSelf(newSource); + document.Save(nugetConfigPath); + } + } }