Microsoft.NET.Sdk.Web missing Web menu (ASP.NET) - asp.net

I try to convert old ASP.NET MVC 5 (349C5851-65DF-11DA-9384-00065B846F21) projects to new format with Microsoft.NET.Sdk.Web.
One main difference is the missing Web menu under Project > Properties. How could I configure these settings in the new format?
Old ASP.NET Project:
New Microsoft.NET.Sdk.Web Project:
File Content of Microsoft.NET.Sdk.Web Project (vbproj)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Deterministic>false</Deterministic>
<TargetFramework>net48</TargetFramework>
<OutputPath>$(SolutionDir)bin\ptc\$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OptionStrict>On</OptionStrict>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputType>Library</OutputType>
<UseIISExpress>true</UseIISExpress>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.7" />
</ItemGroup>
</Project>

Related

Console Application: Program does not contain a static 'Main' method suitable for an entry point - While Main exists

My .NET 5 project's Program.cs looks like this:
using System;
namespace XmlGenerator.Cli
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(("Boo!!!"));
}
}
}
And my project file looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Program.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="Master.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="Program.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Resource Include="Master.xml" />
</ItemGroup>
</Project>
When I try and run the app with F5, I get the following error:
CS5001 Program does not contain a static 'Main' method suitable for an entry point
I certainly does contain a Main, so what could be wrong?
My solution was to delete all the ItemGroup elements from the project file, leaving just:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
</Project>

Could not load type 'Context' from assembly 'Microsoft.AspNetCore.Hosting'

Running my integration tests for some controllers, I get this exception:
Error Message:
System.TypeLoadException : Could not load type 'Context' from assembly
'Microsoft.AspNetCore.Hosting, Version=3.1.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
I've already checked this but not helpful
Could not load type 'Context' from assembly 'Microsoft.AspNetCore.Hosting, Version=3.0.0.0
Here's the list of dependencies in unit test proj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Content Include="..\..\src\MyMicroserviceActio.Api\appsettings.json" Link="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.7.142" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyMicroserviceActio.Api\MyMicroserviceActio.Api.csproj" />
</ItemGroup>
</Project>
And here's an example of a test case:
private readonly TestServer _server;
private readonly HttpClient _client;
public HomeControllerTests()
{
_server = new TestServer(WebHost.CreateDefaultBuilder()
.UseStartup<Startup>());
_client = _server.CreateClient();
}
[Fact]
public async Task home_controller_get_should_return_string_content()
{
var response = await _client.GetAsync("/");
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
content.Should().BeEquivalentTo("Hello from MyMicroserviceActio API!");
}
The whole project is github
You need to bump Microsoft.AspNetCore.TestHost to a compatible 3.x version (PR submitted).

NopCommerce Plugins built within custom plugin

I am using Nopcommerce 4.2 and trying to create a custom Plugin.
At runtime I get the error:
System.Exception: 'A plugin with 'DiscountRequirement.MustBeAssignedToCustomerRole' system name is already defined
When I go to Nop.Web/Plugins, I can see all the plugins that have been built - including mine. When I look in my custom plugin, I can see a folder folder called Plugins, this contains all the other plugins that have been built.
I have looked at my csproj and compared it against nop default plugins and cannot work out why mine builds all the plugins again.
to be clear the structure that is being created is:
Nop.Web
Plugins/
--DiscountRules.CustomerRoles
--ExchangeRate.EcbExchange
--...Other plugins...
--My.Plugin/
----App_Data
----Areas
----Plugins/
-----DiscountRules.CustomerRoles
-----ExchangeRate.EcbExchange
-----...Other plugins...
my project file
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<OutputPath>..\..\Presentation\Nop.Web\Plugins\Widgets.MostViewedProducts</OutputPath>
<OutDir>$(OutputPath)</OutDir>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Domain\**" />
<Content Remove="Domain\**" />
<EmbeddedResource Remove="Domain\**" />
<None Remove="Domain\**" />
</ItemGroup>
<ItemGroup>
<None Remove="logo.jpg" />
<None Remove="plugin.json" />
</ItemGroup>
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Content Include="logo.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Update="Areas\Admin\Views\BuilderProductAttribute\Create.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProductAttribute\Edit.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProductAttribute\List.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Areas\Admin\Views\BuilderProductAttribute\_CreateOrUpdate.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\Create.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\Edit.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\List.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeCatalogCreatePopup.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeMappingCreate.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeMappingEdit.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.Attributes.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.Info.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.SEO.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.Catalog.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.Info.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\ProductBuilder\Configure.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Areas\Admin\Views\_ViewImports.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Views\BuilderProduct\AttributeMappingProduct.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Views\BuilderProduct\Details.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Views\BuilderProduct\ProductDetails.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Views\BuilderProduct\_CatalogSelectors.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Views\BuilderProduct\_ProductBox.ProductBuilder.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Views\_ViewImports.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\Admin\Controllers\" />
<Folder Include="Areas\Admin\Extensions\" />
<Folder Include="Areas\Admin\Factories\" />
<Folder Include="Areas\Admin\Infrastructure\" />
<Folder Include="Areas\Admin\Models\" />
<Folder Include="Areas\Admin\Views\" />
<Folder Include="Controllers\" />
<Folder Include="Extensions\" />
<Folder Include="Factories\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
<ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj" />
<ClearPluginAssemblies Include="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" />
</ItemGroup>
<ItemGroup>
<None Update="Views\Shared\Components\Default.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Views\_ViewImports.cshtml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- This target execute after "Build" target -->
<Target Name="NopTarget" AfterTargets="Build">
<!-- Delete unnecessary libraries from plugins path -->
<MSBuild Projects="#(ClearPluginAssemblies)" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
</Target>
</Project>
EDIT
Plugin.json
{
"InstalledPluginNames": [
"Widgets.GoogleAnalytics",
"Widgets.NivoSlider",
"ExternalAuth.Facebook",
"Misc.Cards",
"Payments.PayPalSmartPaymentButtons",
"Payments.PayPalStandard",
"Catalog.SkipToProduct"
],
"PluginNamesToUninstall": [],
"PluginNamesToDelete": [
"DiscountRequirement.MustBeAssignedToCustomerRole",
"CurrencyExchange.ECB",
"Misc.SendinBlue",
"Payments.CheckMoneyOrder",
"Payments.Manual",
"Payments.Qualpay",
"Payments.Square",
"Pickup.PickupInStore",
"Shipping.FixedByWeightByTotal",
"Shipping.UPS",
"Tax.Avalara",
"Tax.FixedOrByCountryStateZip"
],
"PluginNamesToInstall": []
}
the problem might be a reference, because when you add the reference DiscountRequirement.MustBeAssignedToCustomerRole to another plugin you need to put in the property Copylocal = false.
There are a few places that are having the error. Can't give an answer without checking such as plugin.json, dependencyregister.cs, plugin.cs,etc..
But when you familiar with it you can find your own way to speed up
your developments.
tip: This is the easiest way if you are still getting any issue with your plugin.
Just take a copy of small original plugin such as 'Nop.Plugin.Payments.Qualpay,Square,SendinBlue' and rename then edit .proj file set output folder.
remove all the unnecessary classes, files, and folders except 'DependencyRegistrar.cs,RouteProvider.cs,plugin.json,StartUpPlugin.cs'
change the namespaces of remaining files and remove unnecessary codes.
In plugin.json "SupportedVersions": [ "4.20" ] is a must value
build and clear all the errors.
It should appear on 'Configuration > Local Configuration'
tip: This is the my project building best practice when I'm getting references errors
Clean the solution
go to ~/API/Presentation/Nop.Web/Plugins folder and remove all the build folders.
Right-click on 'Libraries' folder and build it.
Right-click on 'Presentation' folder and build it.
Right-click on 'Plugins' folder and build it.
Good luck..!!
you can refer below as a template
plugin.json ("SupportedVersions": [ "4.20" ] is a must value) otherwise plugin service won't pick your plugin
{
"Group": "Plugin group name",
"FriendlyName": "Elastic Search",
"SystemName": "Custom.Plugin.ElasticSearch",
"Version": "1.56",
"SupportedVersions": [ "4.20" ],
"Author": "Isanka Thalagala",
"DisplayOrder": 27,
"FileName": "Custom.Plugin.ElasticSearch.dll",
"Description": "This plugin provice ilastic search"
}
DependencyRegistrar.cs class
public class DependencyRegistrar : IDependencyRegistrar
{
/// <summary>
/// Register services and interfaces
/// </summary>
/// <param name="builder">Container builder</param>
/// <param name="typeFinder">Type finder</param>
/// <param name="config">Config</param>
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
{
//register service manager
builder.RegisterType<SearchFilterService>().As<ISearchFilterService>().InstancePerLifetimeScope();
builder.RegisterType<ElasticSearchService>().As<IElasticSearchService>().InstancePerLifetimeScope();
}
/// <summary>
/// Gets order of this dependency registrar implementation
/// </summary>
public int Order => 1;
}
ElasticSearchPlugin.cs
public class ElasticSearchPlugin : BasePlugin
{
#region Ctor
public ElasticSearchPlugin()
{
}
#endregion
#region Methods
/// <summary>
/// Install the plugin
/// </summary>
public override void Install()
{
base.Install();
}
/// <summary>
/// Uninstall the plugin
/// </summary>
public override void Uninstall()
{
base.Uninstall();
}
#endregion
/// <summary>
/// Gets a value indicating whether to hide this plugin on the widget list page in the admin area
/// </summary>
public bool HideInWidgetList => true;
}
Please clear your bin and delete all of the plugin under this "Nop.Web -> Plugins" folder once. This works for me.
Thanks

Blazor Core Hosted - all Components in Razor Class Library Project are being printed as HTML on the page

I haven't been able to find the keywords for a similar issue, so I'm posting a new one.
The project was working fine and suddenly the issue described below happened. I was only editing some Razor files from the Razor Class Library, so I was unable to trace it back to any code modification I made.
The Issue:
I have the following project structure:
The Client, Server and Shared are projects that were initially created by the Blazor Template in the NET Core 3.0. DesktopClient is a similar Blazor project with ElectronNET and the issue is also happening on the component over there.The SharedLibrary project is the project where the components common to all projects are placed and where the root of the issue is apparently coming from.
The SharedLibrary is referenced on the Client project so I can access the components in the Client project.
What happened is that suddenly the components from the Razor Class Library stopped being "compiled" and all "#" are being printed as Raw HTML like the button for the "Counter 2":
[]
Notice as how there are 3 buttons on the image. The first one is in the base Razor page and is being compiled correctly. Second one is from the SharedLibrary project and is not being compiled apparently as the "#" tag is not being replaced. And the third button is from a Component in the Client project(same project as the base Razor page) and is also working correctly.
So the issue is that the SharedLibrary Razor files are not being "compiled".
What I've tried:
Remove and add reference from project;
Clean and rebuild solution;
Update packages;
Checked .csproj to see if I could find anything wrong/missing (not experienced on this file, so might have missed something).
Created a new Blazor Core Hosted project and added a Razor Class Library with the same setup as this demo. It worked fine, so the problem in on this project. Dependencies and ".csproj" files seem very similar.
The code:
.csproj for Client project:
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazor.Extensions.SignalR" Version="0.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj" />
<ProjectReference Include="..\Shared\ServerAPI.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\SharedLibrary\Content\styles\font\**\*.*">
<Link>wwwroot\styles\font\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\SharedLibrary\Content\images\system\*.*">
<Link>wwwroot\images\system\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\SharedLibrary\Content\images\social\brands\*.*">
<Link>wwwroot\images\social\brands\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Remove="bin\**" />
<Content Remove="bin\**" />
<EmbeddedResource Remove="bin\**" />
<None Remove="bin\**" />
<Content Remove="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="compilerconfig.json" />
<_ContentIncludedByDefault Remove="wwwroot\styles\main.css" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
<Folder Include="Services\" />
<Folder Include="wwwroot\images\system\" />
<Folder Include="wwwroot\scripts\" />
</ItemGroup>
<ItemGroup>
<None Include="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\styles\main.css">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)" DestinationFiles="%(Content.Link)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Condition="'%(Content.Link)' != ''" />
</Target>
</Project>
.csproj for SharedLibrary
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazor.Extensions.SignalR" Version="0.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Content\images\social\brands\" />
<Folder Include="Core\Login\" />
<Folder Include="Core\Login\OAuth2\" />
<Folder Include="Services\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Resources\Languages\en-US.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>en-US.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\Languages\en-US.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>en-US.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
Index.razor
#page "/"
#using ServerAPI.Client.Components
#using SharedLibrary.Components.User
<h1>Counter</h1>
<p>Current count: #currentCount</p>
<button class="btn btn-primary" #onclick="IncrementCount">Click me</button>
#code {
int currentCount = 0;
void IncrementCount()
{
currentCount++;
}
}
<SocialWithFormLoginComponent />
<Counter />
SocialWithFormLoginComponent.razor in SharedLibrary project
<h1>Counter 2</h1>
<p>Current count 2: #currentCount2</p>
<button class="btn btn-primary" #onclick="IncrementCount2">Click me 2</button>
#code {
int currentCount2 = 0;
void IncrementCount2()
{
currentCount2++;
StateHasChanged();
Console.WriteLine("Hello world!");
}
}
Counter.razor in Client project
<h1>Counter 3</h1>
<p>Current count 3: #currentCount3</p>
<button class="btn btn-primary" #onclick="IncrementCount3">Click me 3</button>
#code {
int currentCount3 = 0;
void IncrementCount3()
{
currentCount3++;
StateHasChanged();
Console.WriteLine("Hello world!");
}
}
Final comments
As you can see the code is very simple for my troubleshooting, however the project is not, so re-creating would be a lot of work.
Any suggestions I might try? I'm really confused here.
Thanks in advance!
Update with solution:
Turns out, as #dani hererra posted, I was missing "_Imports.razor" in the folder on my components from the attached Razor Class library like so:
Check Microsoft.AspNetCore.Components.Web is listed on _Imports.razor:
#using System.Net.Http
#using Microsoft.AspNetCore.Authorization
#using Microsoft.AspNetCore.Components.Authorization
#using Microsoft.AspNetCore.Components.Forms
#using Microsoft.AspNetCore.Components.Routing
#using Microsoft.AspNetCore.Components.Web //<-----
#using Microsoft.JSInterop
#using _your_namespace_
#using _your_namespace_.Shared

Unable to deploy to a local server folder asp.net successfully

I am new to asp.net
Below is my project file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="GatherAllFilesToPublish">
</Target>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F5500ADD-969D-45A1-A175-0D60ECE982B2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleWebService</RootNamespace>
<AssemblyName>SampleWebService</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<UseIISExpress>false</UseIISExpress>
<TargetFrameworkProfile />
<Use64BitIISExpress />
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Content Include="WebService.asmx" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="WebService.asmx.cs">
<DependentUpon>WebService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommonLib\CommonLib.csproj">
<Project>{1B3AF307-D36B-498F-8618-B53688B4FFC6}</Project>
<Name>CommonLib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile1.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile2.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile3.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile4.pubxml" />
<None Include="Properties\PublishProfiles\Profile1.pubxml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>64867</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
When i tried to deploy to a local server by folder,the bin/Release/Publish
does not contain anything.
Also tried the Debug mode too,bin/Debug/Publish folder contains nothing.
When i run publish,below is the following output,
1>------ Publish started: Project: SampleWebService, Configuration: Debug Any CPU ------
1>Connecting to D:\Project\Sample\SampleWebService\SampleWebService\bin\Release\publish\...
1>Publishing folder /...
1>Web App was published successfully file:///D:/Project/Sample/SampleService/SampleWebService/bin/Release/publish/
1>
========== Build: 0 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
The publish log indicates success but no files inside my publish folder.
i am using visual studio 2017 but the project files should be built using 2010
Based on the following lines:
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
V10.0 means visual studio 2010 ,am i right?
Anyone has any idea what is wrong,do i have to use visual studio 2010 to publish my project instead of the latest 2017 version?
Resolved:
The cause is i put the following lines in the project file to resolve the gatherallfilestopublish issue:
</Target>-->
Found another way to resolve the issue as outlined by below forum:
https://forums.asp.net/t/1838524.aspx?The+target+GatherAllFilesToPublish+does+not+exist
Re: The target GatherAllFilesToPublish does not exist
I fixed the issue by doing following modifications to the Project file. have VS 2012 and the web application was MVC 4
Unload the project and start editing the csproj file.
Added following lines.
10.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
Added following lines.(Note that some of the Import statments may already exisits. In such case you do not need to add them.
Project file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--<Target Name="GatherAllFilesToPublish">
</Target>-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F5500ADD-969D-45A1-A175-0D60ECE982B2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleWebService</RootNamespace>
<AssemblyName>SampleWebService</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<UseIISExpress>false</UseIISExpress>
<TargetFrameworkProfile />
<Use64BitIISExpress />
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<!--added-->
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<!--added-->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Content Include="WebService.asmx" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="WebService.asmx.cs">
<DependentUpon>WebService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommonLib\CommonLib.csproj">
<Project>{1B3AF307-D36B-498F-8618-B53688B4FFC6}</Project>
<Name>CommonLib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile1.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile2.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile3.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile4.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile5.pubxml" />
<None Include="Properties\PublishProfiles\Profile1.pubxml" />
</ItemGroup>
<!-- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />-->
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>64867</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Resources