Skip to content

Resurrect Blazor VSIX #6779

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

Merged
merged 14 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 1 addition & 6 deletions build/repo.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@
<!-- These projects are always excluded, even when -projects is specified on command line. -->
<ItemGroup>

<!--
Excluding the Blazor VSIX because MSBuild.exe currently always fails with "error NETSDK1050: The version of Microsoft.NET.Sdk used by this project is insufficient".
This VSIX is going to move into aspnet/AspNetCore-Tooling soon
-->
<ProjectToExclude Include="$(RepositoryRoot)src\Components\Blazor\BlazorExtension\src\Microsoft.VisualStudio.BlazorExtension.csproj" />

<!-- These projects use 'legacy' csproj, which is not supported by dotnet-msbuild. -->
<ProjectToExclude Include="
$(RepositoryRoot)src\Components\Blazor\BlazorExtension\src\Microsoft.VisualStudio.BlazorExtension.csproj;
$(RepositoryRoot)src\Servers\HttpSys\samples\TestClient\TestClient.csproj;
$(RepositoryRoot)src\Middleware\WebSockets\samples\TestServer\TestServer.csproj;
"
Expand Down
1 change: 0 additions & 1 deletion eng/ProjectReferences.props
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR" ProjectPath="$(RepositoryRoot)src\SignalR\server\SignalR\src\Microsoft.AspNetCore.SignalR.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR.Specification.Tests" ProjectPath="$(RepositoryRoot)src\SignalR\server\Specification.Tests\src\Microsoft.AspNetCore.SignalR.Specification.Tests.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" ProjectPath="$(RepositoryRoot)src\SignalR\server\StackExchangeRedis\src\Microsoft.AspNetCore.SignalR.StackExchangeRedis.csproj" />
<ProjectReferenceProvider Include="Microsoft.VisualStudio.LanguageServices.Blazor" ProjectPath="$(RepositoryRoot)src\Components\Blazor\BlazorLanguageServices\src\Microsoft.VisualStudio.LanguageServices.Blazor.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Blazor" ProjectPath="$(RepositoryRoot)src\Components\Blazor\Blazor\src\Microsoft.AspNetCore.Blazor.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Blazor.Build" ProjectPath="$(RepositoryRoot)src\Components\Blazor\Build\src\Microsoft.AspNetCore.Blazor.Build.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Blazor.Server" ProjectPath="$(RepositoryRoot)src\Components\Blazor\Server\src\Microsoft.AspNetCore.Blazor.Server.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.VisualStudio.Shell.Interop;
Expand Down Expand Up @@ -33,12 +33,12 @@ public AutoRebuildService(BuildEventsWatcher buildEventsWatcher)

public void Listen()
{
AddBuildServiceNamedPipeServer();
_ = AddBuildServiceNamedPipeServerAsync();
}

private void AddBuildServiceNamedPipeServer()
private Task AddBuildServiceNamedPipeServerAsync()
{
Task.Factory.StartNew(async () =>
return Task.Factory.StartNew(async () =>
{
try
{
Expand Down Expand Up @@ -69,7 +69,7 @@ private void AddBuildServiceNamedPipeServer()
// As soon as we receive a connection, spin up another background
// listener to wait for the next connection
await serverPipe.WaitForConnectionAsync();
AddBuildServiceNamedPipeServer();
_ = AddBuildServiceNamedPipeServerAsync();

await HandleRequestAsync(serverPipe, isServerElevated);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. 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.Threading.Tasks;
using Microsoft.VisualStudio.ProjectSystem.Properties;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

Expand Down Expand Up @@ -74,14 +73,16 @@ public int OnActiveProjectCfgChange(IVsHierarchy pIVsHierarchy)

public int UpdateProjectCfg_Begin(IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg pCfgSln, uint dwAction, ref int pfCancel)
{
ThreadHelper.ThrowIfNotOnUIThread();

if (IsBlazorProject(pHierProj))
{
// This method runs both for manually-invoked builds and for builds triggered automatically
// by PerformNewBuildAsync(). In the case where it's a manually-invoked build, make sure
// there's an in-progress BuildInfo so that if there are further builds requests while the
// build is still in progress we can join them onto this existing build.
var ctx = (IVsBrowseObjectContext)pCfgProj;
var projectPath = ctx.UnconfiguredProject.FullPath;

var projectPath = GetProjectPath(pHierProj);
lock (mostRecentBuildInfosLock)
{
var hasBuildInProgress =
Expand All @@ -99,11 +100,12 @@ public int UpdateProjectCfg_Begin(IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCf

public int UpdateProjectCfg_Done(IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg pCfgSln, uint dwAction, int fSuccess, int fCancel)
{
ThreadHelper.ThrowIfNotOnUIThread();

if (IsBlazorProject(pHierProj))
{
var buildResult = fSuccess == 1;
var ctx = (IVsBrowseObjectContext)pCfgProj;
var projectPath = ctx.UnconfiguredProject.FullPath;
var projectPath = GetProjectPath(pHierProj);

// Mark pending build info as completed
BuildInfo foundInfo = null;
Expand Down Expand Up @@ -160,6 +162,13 @@ private async Task<bool> PerformNewBuildAsync(string projectPath, BuildInfo buil
private static bool IsBlazorProject(IVsHierarchy pHierProj)
=> pHierProj.IsCapabilityMatch(BlazorProjectCapability);

private static string GetProjectPath(IVsHierarchy pHierProj)
{
ThreadHelper.ThrowIfNotOnUIThread();
ErrorHandler.ThrowOnFailure(((IVsProject)pHierProj).GetMkDocument((uint)VSConstants.VSITEMID.Root, out var projectPath), VSConstants.E_NOTIMPL);
return projectPath;
}

class BuildInfo
{
public DateTime StartTime { get; }
Expand Down
38 changes: 21 additions & 17 deletions src/Components/Blazor/BlazorExtension/src/BlazorPackage.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. 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.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;

namespace Microsoft.VisualStudio.BlazorExtension
{
// We mainly have a package so we can have an "About" dialog entry.
[PackageRegistration(UseManagedResourcesOnly = true)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[AboutDialogInfo(PackageGuidString, "ASP.NET Core Blazor Language Services", "#110", "112")]
[Guid(BlazorPackage.PackageGuidString)]
[ProvideAutoLoad(UIContextGuids80.SolutionExists)]
public sealed class BlazorPackage : Package
[ProvideAutoLoad(UIContextGuids80.SolutionExists, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class BlazorPackage : AsyncPackage
{
public const string PackageGuidString = "d9fe04bc-57a7-4107-915e-3a5c2f9e19fb";

protected override void Initialize()
protected async override Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
base.Initialize();
RegisterAutoRebuildService();
}
await base.InitializeAsync(cancellationToken, progress);

private void RegisterAutoRebuildService()
{
ThreadHelper.ThrowIfNotOnUIThread();
await JoinableTaskFactory.SwitchToMainThreadAsync();

// Create build watcher. No need to unadvise, as this only happens once anyway.
var solution = (IVsSolution)GetGlobalService(typeof(IVsSolution));
var buildManager = (IVsSolutionBuildManager)GetService(typeof(SVsSolutionBuildManager));
var buildWatcher = new BuildEventsWatcher(solution, buildManager);
var hr = buildManager.AdviseUpdateSolutionEvents(buildWatcher, out var cookie);
Marshal.ThrowExceptionForHR(hr);
var solution = (IVsSolution)await GetServiceAsync(typeof(IVsSolution));
var buildManager = (IVsSolutionBuildManager)await GetServiceAsync(typeof(SVsSolutionBuildManager));

// According to the docs, this can happen if VS shuts down while our package is loading.
if (solution == null || buildManager == null)
{
var buildWatcher = new BuildEventsWatcher(solution, buildManager);
var hr = buildManager.AdviseUpdateSolutionEvents(buildWatcher, out var cookie);
Marshal.ThrowExceptionForHR(hr);

new AutoRebuildService(buildWatcher).Listen();
new AutoRebuildService(buildWatcher).Listen();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
<ImportDirectoryBuildTargets>true</ImportDirectoryBuildTargets>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<!-- Other projects should not reference this assembly. It is only mean to be used in Visual Studio. -->
<!-- Other projects should not reference this assembly. It is only meaning to be used in Visual Studio. -->
<IsProjectReferenceProvider>false</IsProjectReferenceProvider>
<IsShippingPackage>false</IsShippingPackage>
<IsPackable>false</IsPackable>
<EnableSourceLink>false</EnableSourceLink>
<GenerateSourceLinkFile>false</GenerateSourceLinkFile>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

<!--
Since the VSSDK doeesn't support SDK-based projects, we have to use the long/verbose version.

Expand All @@ -20,26 +25,23 @@

BEGIN INTERESTING STUFF
-->
<PropertyGroup>
<!-- VSIXes are always signed. This is the same key that ASP.NET uses for OSS signing -->
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\eng\AspNetCore.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<!--
Following VS convention of using the VS release # as a convention for the vsix version.

VS needs this build number to be parsable by System.Version, so it can't have any letters.
VS needs this build number to be parsable by System.Version, so it can't have any letters or a - which
is used by our build system.
-->
<VsixVersion>15.7</VsixVersion>
<VsixVersion Condition="'$(BuildNumber)'!='' AND '$(BuildNumber)'!='t000'">$(VsixVersion).$(BuildNumber)</VsixVersion>
<VsixVersion Condition="'$(BuildNumber)'=='' AND '$(CI)'!='true'">$(VsixVersion).999999</VsixVersion>
<VsixVersion Condition="'$(BuildNumber)'=='' AND '$(CI)'=='true'">$(VsixVersion).ERROR-MISSING_BUILD_NUMBER</VsixVersion>
<VsixVersionPrefix>16.0</VsixVersionPrefix>
<VsixVersionSuffix Condition="'$(BuildNumberSuffix)'=='t000'">424242.424242</VsixVersionSuffix>
<VsixVersionSuffix Condition="'$(VsixVersionSuffix)'==''">$(BuildNumberSuffix.Replace('-', '.'))</VsixVersionSuffix>
<VsixVersion>$(VsixVersionPrefix).$(VsixVersionSuffix)</VsixVersion>
</PropertyGroup>
<!--
Used by the .vsixmanifest to insert the the VSIX version based on $(VsixVersion)
-->
<Target Name="GetBuildVersion" Outputs="$(VsixVersion)" />

<PropertyGroup>
<!-- Use the same experimental hive as Roslyn and Razor. This makes it easy to mix private builds. -->
<StartAction>Program</StartAction>
Expand Down Expand Up @@ -71,7 +73,7 @@
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
</PropertyGroup>
<Target Name="PreCreateVsixContainer" BeforeTargets="CreateVsixContainer">
<Target Name="PreCreateVsixContainer" BeforeTargets="GetVsixSourceItems">
<ItemGroup>
<VSIXSourceItem Include="$(ArtifactsShippingPackagesDir)Microsoft.AspNetCore.Blazor.Templates.*.nupkg">
<VSIXSubPath>ProjectTemplates\</VSIXSubPath>
Expand All @@ -89,25 +91,7 @@
<Target Name="CopySymbolsToOutput" AfterTargets="Build" Condition="'$(SymbolsPublishDir)' != ''">
<Copy SourceFiles="$(OutDir)$(AssemblyName).pdb" DestinationFolder="$(SymbolsPublishDir)" />
</Target>
<!--
We should be really careful about what goes into the VSIX and what doesn't. Since we're using
P2P references and packages, there are some things we need to exclude.

We want everything that *we* don't own to be excluded, those dependencies need to be satisfied
by other VS components (Razor, Roslyn).

Ideally we could use an allow-list here, but I don't know how to do that.
-->
<ItemDefinitionGroup>
<SuppressFromVsix>
<Visible>false</Visible>
</SuppressFromVsix>
</ItemDefinitionGroup>
<ItemGroup>
<SuppressFromVsix Include="Microsoft.AspNetCore.Razor.Language.dll" />
<SuppressFromVsix Include="Microsoft.CodeAnalysis.Razor.dll" />
<SuppressFromVsix Include="Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
</ItemGroup>
<ItemGroup>
<!--
Let's continue our parade of gross workarounds.
Expand All @@ -124,27 +108,13 @@
<ProjectReference Include="..\..\Templates\src\Microsoft.AspNetCore.Blazor.Templates.csproj">
<Project>{edd21533-c6e6-4f85-be4f-10e06756e24c}</Project>
<Name>Microsoft.AspNetCore.Blazor.Templates</Name>
<Targets>Pack</Targets>
<Private>False</Private>
<IncludeOutputGroupsInVSIX>
</IncludeOutputGroupsInVSIX>
<IncludeOutputGroupsInVSIXLocalOnly>
</IncludeOutputGroupsInVSIXLocalOnly>
</ProjectReference>
<ProjectReference Include="..\..\BlazorLanguageServices\src\Microsoft.VisualStudio.LanguageServices.Blazor.csproj">
<Project>{b9f7f502-6dd2-4e77-8fd1-cbd76f695b26}</Project>
<Name>Microsoft.VisualStudio.LanguageServices.Blazor</Name>
<Private>False</Private>
<IncludeOutputGroupsInVSIX>
</IncludeOutputGroupsInVSIX>
<IncludeOutputGroupsInVSIXLocalOnly>
</IncludeOutputGroupsInVSIXLocalOnly>
</ProjectReference>
<Content Include="..\..\BlazorLanguageServices\src\bin\$(Configuration)\net461\Microsoft.VisualStudio.LanguageServices.Blazor.dll">
<Link>Microsoft.VisualStudio.LanguageServices.Blazor.dll</Link>
<IncludeInVSIX>true</IncludeInVSIX>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
</ItemGroup>
<!--
We need to generate the assembly attributes for our assembly using the version from the build, so
Expand Down Expand Up @@ -189,7 +159,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.VisualStudio.BlazorExtension</RootNamespace>
<AssemblyName>Microsoft.VisualStudio.BlazorExtension</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -208,33 +178,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.CoreUtility" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Imaging" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.OLE.Interop" Version="7.10.6071" />
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem" Version="15.3.224" />
<PackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.16" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Framework" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop" Version="7.10.6072" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.10.0" Version="10.0.30320" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.11.0" Version="11.0.61031" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.12.0" Version="12.0.30110" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.8.0" Version="8.0.50728" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.9.0" Version="9.0.30730" />
<PackageReference Include="Microsoft.VisualStudio.TextManager.Interop" Version="7.10.6071" />
<PackageReference Include="Microsoft.VisualStudio.TextManager.Interop.8.0" Version="8.0.50728" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="15.6.46" />
<PackageReference Include="Microsoft.VisualStudio.Utilities" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="15.3.15" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.5.100" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.7.27703" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.9.3032" />
<PackageReference Include="StreamJsonRpc" Version="1.5.43" />
</ItemGroup>
<ItemGroup>
<Compile Include="AboutDialogInfoAttribute.cs" />
<Compile Include="AutoRebuild\AutoRebuildService.cs" />
<Compile Include="AutoRebuild\BuildEventsWatcher.cs" />
<Compile Include="AutoRebuild\StreamProtocolExtensions.cs" />
<Compile Include="BlazorPackage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="CodeSnippets\Blazor\para.snippet">
Expand Down Expand Up @@ -306,4 +259,8 @@
<_GeneratedVSIXAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).VSIXAssemblyInfo.cache.txt</_GeneratedVSIXAssemblyInfoInputsCacheFile>
<_GeneratedVSIXAssemblyInfoFile>$(IntermediateOutputPath)$(MSBuildProjectName).VSIXAssemblyInfo.cs</_GeneratedVSIXAssemblyInfoFile>
</PropertyGroup>

<!-- This needs to be here because the build will try to call it -->
<Target Name="Pack">
</Target>
</Project>

This file was deleted.

2 changes: 1 addition & 1 deletion src/Components/Blazor/BlazorExtension/src/Templates.pkgdef
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[$RootKey$\TemplateEngine\Templates\Blazor\0.2.0]
[$RootKey$\TemplateEngine\Templates\Blazor\0.8.0]
"InstalledPath"="$PackageFolder$\ProjectTemplates"
Loading