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

Missing NuGet for latest Microsoft.AspNetCore.Http.Abstractions preview #9611

Closed
stsrki opened this issue Apr 21, 2019 · 8 comments
Closed
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question
Milestone

Comments

@stsrki
Copy link
Contributor

stsrki commented Apr 21, 2019

I have a component library that is configured to work for Blazor and for Razor Components. In the previous version of Blazor/RC there was a version 3.0.0-preview3-19153-02 of Microsoft.AspNetCore.Http.Abstractions that matched the .Net Core 3 preview number. Now in the latest preview 4 there is no equivalent package to be found.

Questions:

  1. Should there be a version 3.0.0-preview4-19216-03 of Microsoft.AspNetCore.Http.Abstractions?

  2. If not, what version should I include in my build process so that users of my library can safely add my NuGet packages without breaking anything?

Additional info:

For your reference, current version of build configuration for preview 3 can be found on https://github.com/stsrki/Blazorise/blob/master/Build/Blazorise.props

@neven10
Copy link

neven10 commented Apr 21, 2019

Probably related

#8527

If you look at
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.0.0-preview4-19216-03
you'll find Microsoft.AspNetCore.Http.Abstractions so you don't have to reference it individually.

@blowdart blowdart added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Apr 21, 2019
@stsrki
Copy link
Contributor Author

stsrki commented Apr 21, 2019

@neven10 thanks for pointing me in the right direction. I have managed to make it work by just adding a FrameworkReference instead of PackageReference.

Example

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
	<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

@rynowak
Copy link
Member

rynowak commented Apr 21, 2019

This is the correct thing to do if you need to reference Microsoft.AspNetCore.Http.Abstractions for some reason.

However, I'm a little concerned if you end up needing libraries from the server side framework in a general-purpose component library. This is going to negatively impact app size for client-side Blazor. I'd be interested to know what your needs are, and if we can address them in some other way.

@neven10
Copy link

neven10 commented Apr 21, 2019

Weren't there plans to implement some sort of tree shaking in client side blazor? Like JS SPAs do?
I think i've read that somewhere.

@rynowak
Copy link
Member

rynowak commented Apr 21, 2019

We already have support for running the mono linker - that's not a cure-all though. Suppose that you're using part of HttpAbstractions that has a really thick set of real dependencies (Span, Memory, vectorized string operations) - those won't be linked out because they are needed.

We're trying to avoid you needing our server-side stack inside a client-side app.

@rynowak rynowak added this to the Discussions milestone Apr 21, 2019
@stsrki
Copy link
Contributor Author

stsrki commented Apr 22, 2019

@rynowak The only thing that I need from Microsoft.AspNetCore.Http.Abstractions is IApplicationBuilder. I need it so I can register custom implementation of my "base" components in Blazorise, which is my root library. The base library contains all of the components with default behaviour and then I have custom implementation for Bootstrap, Bulma, Material etc.

By using IApplicationBuilder or IComponentsApplicationBuilder I can get IServiceProvider with which I can register custom components. Registered components are later rendered by using RenderTreeBuilder.

In the following example you can see how I register some of the components for Bootstrap implementation:

private static void RegisterComponents( IComponentMapper componentMapper )
        {
            componentMapper.Register<Blazorise.Addon, Bootstrap.Addon>();
            componentMapper.Register<Blazorise.BarToggler, Bootstrap.BarToggler>();
            componentMapper.Register<Blazorise.BarDropdown, Bootstrap.BarDropdown>();
            componentMapper.Register<Blazorise.CardSubtitle, Bootstrap.CardSubtitle>();
            componentMapper.Register<Blazorise.CloseButton, Bootstrap.CloseButton>();
            componentMapper.Register<Blazorise.CheckEdit, Bootstrap.CheckEdit>();
            componentMapper.Register<Blazorise.Field, Bootstrap.Field>();
            componentMapper.Register<Blazorise.FieldBody, Bootstrap.FieldBody>();
            componentMapper.Register<Blazorise.FileEdit, Bootstrap.FileEdit>();
            componentMapper.Register<Blazorise.ModalContent, Bootstrap.ModalContent>();
            componentMapper.Register<Blazorise.SimpleButton, Bootstrap.SimpleButton>();
        }

#if NETSTANDARD2_0

        public static IComponentsApplicationBuilder UseBootstrapProviders( this IComponentsApplicationBuilder app )
        {
            var componentMapper = app.Services.GetRequiredService<IComponentMapper>();

            RegisterComponents( componentMapper );

            return app;
        }

#else // netcoreapp3.0

        public static IApplicationBuilder UseBootstrapProviders( this IApplicationBuilder app )
        {
            var componentMapper = app.ApplicationServices.GetRequiredService<IComponentMapper>();

            RegisterComponents( componentMapper );

            return app;
        }

#endif

and then I call it on the application Startup:

app
    .UseBootstrapProviders();

This way I can have same usage for both Blazor(client-side) and for RC(server-side).

I could create extension methods based on IServiceProvider but then I couldn't chain my registration for other libraries like:

app
    .UseBootstrapProviders()
    .UseFontAwesomeIcons();

@stsrki
Copy link
Contributor Author

stsrki commented Apr 22, 2019

PS. This is the configuration for my project(s) now adjusted for .Net Core 3-preview 4

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<PropertyGroup>
		<Version>0.6.4-preview1-19154-02</Version>
		<PackageVersion>0.6.4-preview1-19154-02</PackageVersion>

		<Description>Blazorise is a component library built on top of Blazor and CSS frameworks like Bootstrap, Bulma and Material.</Description>
		<Authors>Mladen Macanovic</Authors>
		<Company></Company>
		<Copyright>Copyright 2019 Mladen Macanovic</Copyright>
		<RepositoryUrl>https://github.com/stsrki/Blazorise</RepositoryUrl>
		<RepositoryType>git</RepositoryType>
		
		<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
		<OutputType>Library</OutputType>
		<IsPackable>true</IsPackable>   
		<LangVersion>7.3</LangVersion>

		<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
		
		<_RazorComponentInclude>*.cshtml</_RazorComponentInclude>
		
		<RestoreAdditionalProjectSources>
			https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
			https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
		</RestoreAdditionalProjectSources>

		<RazorLangVersion>3.0</RazorLangVersion>
		<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
	</PropertyGroup>
	
	<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
		<DefineConstants>$(DefineConstants);NETSTANDARD2_0</DefineConstants>
	</PropertyGroup>
	
	<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
		<DefineConstants>$(DefineConstants);NETCORE3_0</DefineConstants>
	</PropertyGroup>

	<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
		<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview4-19216-03" />
	</ItemGroup>

	<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
		<FrameworkReference Include="Microsoft.AspNetCore.App" />
	</ItemGroup>
</Project>

@ghost
Copy link

ghost commented Dec 7, 2019

Thank you for contacting us. Due to no activity on this issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

@ghost ghost closed this as completed Dec 7, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2019
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question
Projects
None yet
Development

No branches or pull requests

4 participants