Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profile generators for Visual Studio #7774

Merged
merged 16 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<!-- Dependencies that we can turn on to force override for testing purposes before uploading. -->
<!--<add key="Static Package Dependencies" value="dep\packages" />-->
<add key="TerminalDependencies" value="https://pkgs.dev.azure.com/ms/terminal/_packaging/TerminalDependencies/nuget/v3/index.json" />
<!-- !!! THIS NEEDS TO BE REMOVED BEFORE MERGE. The Microsoft.VisualStudio.Setup.Configuration.Native package needs to be added to the upstream source !!! -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: tabbing off.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not worried about it, becuase it needs to be removed before this can merge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zadjii-msft , @DHowett How do I get Microsoft.VisualStudio.Setup.Configuration.Native served from your single nuget source?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna also /cc @miniksa since he's most familiar with the CI stuff and can probably get to this before me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During conflict resolution, you can finally back this one on out 😄

</packageSources>
<disabledPackageSources>
<clear />
Expand Down
12 changes: 0 additions & 12 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.pre.props" />
<Import Project="..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props" Condition="Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" />
<ItemDefinitionGroup>

<ClCompile>
<!-- For CLI11: It uses dynamic_cast to cast types around, which depends
on being compiled with RTTI (/GR). -->
Expand Down Expand Up @@ -70,7 +69,6 @@
<ClInclude Include="ActionPaletteItem.h" />
<ClInclude Include="App.base.h" />
<ClInclude Include="AppCommandlineArgs.h" />
<ClInclude Include="BaseVisualStudioGenerator.h" />
<ClInclude Include="Commandline.h" />
<ClInclude Include="CommandLinePaletteItem.h" />
<ClInclude Include="Jumplist.h" />
Expand Down Expand Up @@ -128,9 +126,6 @@
<DependentUpon>EmptyStringVisibilityConverter.idl</DependentUpon>
</ClInclude>
<ClInclude Include="Pane.h" />
<ClInclude Include="VsDevCmdGenerator.h" />
<ClInclude Include="VsDevShellGenerator.h" />
<ClInclude Include="VsSetupConfiguration.h" />
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="ShortcutActionDispatch.h">
Expand All @@ -152,7 +147,6 @@
<ItemGroup>
<ClCompile Include="ActionPaletteItem.cpp" />
<ClCompile Include="CommandLinePaletteItem.cpp" />
<ClCompile Include="BaseVisualStudioGenerator.cpp" />
<ClCompile Include="init.cpp" />
<ClCompile Include="AppCommandlineArgs.cpp" />
<ClCompile Include="Commandline.cpp" />
Expand Down Expand Up @@ -219,9 +213,6 @@
<DependentUpon>EmptyStringVisibilityConverter.idl</DependentUpon>
</ClCompile>
<ClCompile Include="Pane.cpp" />
<ClCompile Include="VsDevCmdGenerator.cpp" />
<ClCompile Include="VsDevShellGenerator.cpp" />
<ClCompile Include="VsSetupConfiguration.cpp" />
<ClCompile Include="Pane.LayoutSizeNode.cpp" />
<ClCompile Include="ColorHelper.cpp" />
<ClCompile Include="DebugTapConnection.cpp" />
Expand All @@ -245,7 +236,6 @@
</ClCompile>
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="Toast.cpp" />

</ItemGroup>
<!-- ========================= idl Files ======================== -->
<ItemGroup>
Expand Down Expand Up @@ -389,7 +379,6 @@
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.post.props" />
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
<Import Project="..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
Expand Down Expand Up @@ -417,6 +406,5 @@
</PackagingOutputs>
</ItemGroup>
</Target>

<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
</Project>
31 changes: 1 addition & 30 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
<ClCompile Include="ColorHelper.cpp" />
<ClCompile Include="DebugTapConnection.cpp" />
<ClCompile Include="Jumplist.cpp" />
<ClCompile Include="Tab.cpp">
<Filter>tab</Filter>
</ClCompile>
<ClCompile Include="SettingsTab.cpp">
<Filter>tab</Filter>
</ClCompile>
Expand All @@ -45,18 +42,6 @@
<ClCompile Include="HighlightedText.cpp">
<Filter>highlightedText</Filter>
</ClCompile>
<ClCompile Include="VsSetupConfiguration.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="VsDevShellGenerator.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="VsDevCmdGenerator.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="BaseVisualStudioGenerator.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="Toast.cpp" />
<ClCompile Include="LanguageProfileNotifier.cpp" />
</ItemGroup>
Expand All @@ -73,9 +58,6 @@
<ClInclude Include="DebugTapConnection.h" />
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="Jumplist.h" />
<ClInclude Include="Tab.h">
<Filter>tab</Filter>
</ClInclude>
<ClInclude Include="SettingsTab.h">
<Filter>tab</Filter>
</ClInclude>
Expand All @@ -97,18 +79,6 @@
<ClInclude Include="HighlightedText.h">
<Filter>highlightedText</Filter>
</ClInclude>
<ClInclude Include="VsSetupConfiguration.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="VsDevShellGenerator.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="BaseVisualStudioGenerator.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="VsDevCmdGenerator.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="Toast.h" />
<ClInclude Include="LanguageProfileNotifier.h" />
</ItemGroup>
Expand Down Expand Up @@ -141,6 +111,7 @@
<Midl Include="PaletteItemTemplateSelector.idl" />
<Midl Include="TabBase.idl" />
<Midl Include="EmptyStringVisibilityConverter.idl" />
<Midl Include="TaskbarState.idl" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalApp/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.1.3" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.5.0-prerelease.201202003" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.210309.3" targetFramework="native" />
<package id="Microsoft.VisualStudio.Setup.Configuration.Native" version="2.3.2262" targetFramework="native" developmentDependency="true" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#include "BaseVisualStudioGenerator.h"
#include "DefaultProfileUtils.h"

std::vector<winrt::TerminalApp::Profile> TerminalApp::BaseVisualStudioGenerator::GenerateProfiles()
using namespace Microsoft::Terminal::Settings;
using namespace winrt::Microsoft::Terminal::Settings::Model;

std::vector<Profile>
Model::BaseVisualStudioGenerator::GenerateProfiles()
{
std::vector<winrt::TerminalApp::Profile> profiles;
std::vector<Profile> profiles;

// There's no point in enumerating valid Visual Studio instances more than once,
// so cache them for use by both Visual Studio profile generators.
Expand All @@ -27,7 +31,7 @@ std::vector<winrt::TerminalApp::Profile> TerminalApp::BaseVisualStudioGenerator:
auto DevShell{ CreateDefaultProfile(GetProfileName(instance)) };
DevShell.Commandline(GetProfileCommandLine(instance));
DevShell.StartingDirectory(instance.GetInstallationPath());
DevShell.IconPath(GetProfileIconPath());
DevShell.Icon(GetProfileIconPath());

profiles.emplace_back(DevShell);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Author(s):
#include "IDynamicProfileGenerator.h"
#include "VsSetupConfiguration.h"

namespace TerminalApp
namespace Microsoft::Terminal::Settings::Model
{
class BaseVisualStudioGenerator : public TerminalApp::IDynamicProfileGenerator
class BaseVisualStudioGenerator : public IDynamicProfileGenerator
{
virtual bool IsInstanceValid(const VsSetupConfiguration::VsSetupInstance instance) const = 0;
virtual std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance instance) const = 0;
Expand All @@ -29,7 +29,7 @@ namespace TerminalApp

// Inherited via IDynamicProfileGenerator
virtual std::wstring_view GetNamespace() override = 0;
std::vector<winrt::TerminalApp::Profile> GenerateProfiles() override;
std::vector<winrt::Microsoft::Terminal::Settings::Model::Profile> GenerateProfiles() override;

private:
inline static bool hasQueried = false;
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "AzureCloudShellGenerator.h"
#include "PowershellCoreProfileGenerator.h"
#include "VsDevCmdGenerator.h"
#include "VsDevShellGenerator.h"
#include "WslDistroGenerator.h"

using namespace ::Microsoft::Terminal::Settings::Model;
Expand Down Expand Up @@ -51,6 +53,8 @@ CascadiaSettings::CascadiaSettings(const bool addDynamicProfiles) :
_profileGenerators.emplace_back(std::make_unique<PowershellCoreProfileGenerator>());
_profileGenerators.emplace_back(std::make_unique<WslDistroGenerator>());
_profileGenerators.emplace_back(std::make_unique<AzureCloudShellGenerator>());
_profileGenerators.emplace_back(std::make_unique<VsDevCmdGenerator>());
_profileGenerators.emplace_back(std::make_unique<VsDevShellGenerator>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</PropertyGroup>
<Import Project="..\..\..\common.openconsole.props" Condition="'$(OpenConsoleDir)'==''" />
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.pre.props" />

<!-- ========================= Headers ======================== -->
<ItemGroup>
<ClInclude Include="BaseVisualStudioGenerator.h" />
<ClInclude Include="DefaultTerminal.h">
<DependentUpon>DefaultTerminal.idl</DependentUpon>
</ClInclude>
Expand Down Expand Up @@ -77,10 +77,14 @@
<ClInclude Include="TerminalWarnings.h">
<DependentUpon>TerminalWarnings.idl</DependentUpon>
</ClInclude>
<ClInclude Include="VsDevCmdGenerator.h" />
<ClInclude Include="VsDevShellGenerator.h" />
<ClInclude Include="VsSetupConfiguration.h" />
<ClInclude Include="WslDistroGenerator.h" />
</ItemGroup>
<!-- ========================= Cpp Files ======================== -->
<ItemGroup>
<ClCompile Include="BaseVisualStudioGenerator.cpp" />
<ClCompile Include="DefaultTerminal.cpp">
<DependentUpon>DefaultTerminal.idl</DependentUpon>
</ClCompile>
Expand Down Expand Up @@ -143,6 +147,9 @@
<ClCompile Include="EnumMappings.cpp">
<DependentUpon>EnumMappings.idl</DependentUpon>
</ClCompile>
<ClCompile Include="VsDevCmdGenerator.cpp" />
<ClCompile Include="VsDevShellGenerator.cpp" />
<ClCompile Include="VsSetupConfiguration.cpp" />
<ClCompile Include="WslDistroGenerator.cpp" />
<!-- You _NEED_ to include this file and the jsoncpp IncludePath (below) if
you want to use jsoncpp -->
Expand Down Expand Up @@ -234,13 +241,13 @@
</ItemDefinitionGroup>
<!-- ========================= Globals ======================== -->
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.post.props" />

<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets'))" />
</Target>
<!-- This target will take our defaults.json and stamp it into a .h file that
we can include in the code directly. This way, we don't need to worry about
Expand All @@ -256,6 +263,6 @@
<Target Name="_TerminalAppGenerateUserSettingsH" Inputs="userDefaults.json" Outputs="Generated Files\userDefaults.h" BeforeTargets="BeforeClCompile">
<Exec Command="powershell.exe -noprofile –ExecutionPolicy Unrestricted $(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1 -JsonFile userDefaults.json -OutPath '&quot;Generated Files\userDefaults.h&quot;' -VariableName UserSettingsJson" />
</Target>

<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
</Project>
<Import Project="..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets')" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
<ClCompile Include="IconPathConverter.cpp" />
<ClCompile Include="DefaultTerminal.cpp" />
<ClCompile Include="FileUtils.cpp" />
<ClCompile Include="BaseVisualStudioGenerator.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="VsDevCmdGenerator.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="VsDevShellGenerator.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
<ClCompile Include="VsSetupConfiguration.cpp">
<Filter>profileGeneration</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand Down Expand Up @@ -68,6 +80,18 @@
<ClInclude Include="DefaultTerminal.h" />
<ClInclude Include="FileUtils.h" />
<ClInclude Include="HashUtils.h" />
<ClInclude Include="BaseVisualStudioGenerator.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="VsDevCmdGenerator.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="VsDevShellGenerator.h">
<Filter>profileGeneration</Filter>
</ClInclude>
<ClInclude Include="VsSetupConfiguration.h">
<Filter>profileGeneration</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Midl Include="ActionArgs.idl" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "pch.h"
#include "VsDevCmdGenerator.h"

std::wstring TerminalApp::VsDevCmdGenerator::GetProfileName(const VsSetupConfiguration::VsSetupInstance instance) const
using namespace Microsoft::Terminal::Settings::Model;

std::wstring VsDevCmdGenerator::GetProfileName(const VsSetupConfiguration::VsSetupInstance instance) const
{
std::wstring name{ L"Developer Command Prompt for VS " };
name.append(instance.GetProductLineVersion());
Expand All @@ -19,7 +21,7 @@ std::wstring TerminalApp::VsDevCmdGenerator::GetProfileName(const VsSetupConfigu
return name;
}

std::wstring TerminalApp::VsDevCmdGenerator::GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance instance) const
std::wstring VsDevCmdGenerator::GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance instance) const
{
std::wstring commandLine{ L"cmd.exe /k \"" + instance.GetDevCmdScriptPath() + L"\"" };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ Author(s):
#pragma once
#include "BaseVisualStudioGenerator.h"

namespace TerminalApp
namespace Microsoft::Terminal::Settings::Model
{
class VsDevCmdGenerator :
public TerminalApp::BaseVisualStudioGenerator
class VsDevCmdGenerator : public BaseVisualStudioGenerator
{
public:
VsDevCmdGenerator() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "DefaultProfileUtils.h"
#include "VsSetupConfiguration.h"

std::wstring TerminalApp::VsDevShellGenerator::GetProfileName(const VsSetupConfiguration::VsSetupInstance instance) const
using namespace Microsoft::Terminal::Settings::Model;

std::wstring VsDevShellGenerator::GetProfileName(const VsSetupConfiguration::VsSetupInstance instance) const
{
std::wstring name{ L"Developer PowerShell for VS " };
name.append(instance.GetProductLineVersion());
Expand All @@ -22,7 +24,7 @@ std::wstring TerminalApp::VsDevShellGenerator::GetProfileName(const VsSetupConfi
return name;
}

std::wstring TerminalApp::VsDevShellGenerator::GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance instance) const
std::wstring VsDevShellGenerator::GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance instance) const
{
// The triple-quotes are a PowerShell path escape sequence that can safely be stored in a JSON object.
// The "SkipAutomaticLocation" parameter will prevent "Enter-VsDevShell" from automatially setting the shell path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ Author(s):
#pragma once
#include "BaseVisualStudioGenerator.h"

namespace TerminalApp
namespace Microsoft::Terminal::Settings::Model
{
class VsDevShellGenerator :
public TerminalApp::BaseVisualStudioGenerator
class VsDevShellGenerator : public BaseVisualStudioGenerator
{
public:
VsDevShellGenerator() = default;
Expand Down
Loading