Open Closed

Unable to add Basic-theme properly #1742


User avatar
0
learnabp created
  • ABP Framework version: v4.0.0

  • UI type: MVC

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Separated (Angular): no

  • Exception message and stack trace:

Severity Code Description Project File Line Suppression State Error NU1101 Unable to find package Volo.Abp.AspNetCore.Tests. No packages exist with this id in source(s): ABP Commercial NuGet Source, BlazoriseMyGet, Microsoft Visual Studio Offline Packages, nuget.org Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests C:\LearnAbp\440\Acme.Bookstore\modules\Volo.BasicTheme\test\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj 1

  • Steps to reproduce the issue:"

Created new 4.4.0 using app template and then tried to add the basic-theme scourcecode using the following command

C:\LearnAbp\440\Acme.Bookstore>abp add-module Volo.BasicTheme --with-source-code --add-to-solution-file

it seems it can't find Volo.Abp.AspNetCore.Tests nuget package

please help trying to create a preview video to demo new funtionality of 4.4.0


4 Answer(s)
  • User Avatar
    0
    learnabp created

    The template which is being downloaded for the Basic-Theme has a lot of issues which need resolving after it has been added to the solution

    The Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj file show contacing the following packages

    <PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="4.4.0" />
    <PackageReference Include="Volo.Abp.Autofac" Version="4.4.0" />
    <PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="4.4.0" />
    <PackageReference Include="NSubstitute" Version="4.2.2" />
    <PackageReference Include="Shouldly" Version="4.0.3" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
    

    especially the following

    <PackageReference Include="Volo.Abp.AspNetCore.Tests" Version="4.4.0" />

    should be replaced with

    <PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="4.4.0" />

    the following lines also need to be added to AbpAspNetCoreMvcUiBootstrapDemoTestBase.cs file of Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj project

    public abstract class AbpAspNetCoreMvcUiBootstrapDemoTestBase : AbpAspNetCoreTestBase<TestStartup>

    to

    public abstract class AbpAspNetCoreMvcUiBootstrapDemoTestBase : AbpAspNetCoreIntegratedTestBase<TestStartup>

    the following lines also need to be added to AbpAspNetCoreMvcUiBootstrapDemoTestBase.cs file of Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj project

        protected virtual async Task&lt;string&gt; GetResponseAsStringAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
        {
            using (var response = await GetResponseAsync(url, expectedStatusCode))
            {
                return await response.Content.ReadAsStringAsync();
            }
        }
    
        protected virtual async Task&lt;HttpResponseMessage&gt; GetResponseAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
        {
            using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, url))
            {
                requestMessage.Headers.Add("Accept-Language", CultureInfo.CurrentUICulture.Name);
                var response = await Client.SendAsync(requestMessage);
                response.StatusCode.ShouldBe(expectedStatusCode);
                return response;
            }
        }
    

    the file AbpAspNetCoreMvcUiBootstrapDemoTestBase.cs should be as follows

    using System;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Hosting;
    using Shouldly;
    using Volo.Abp.AspNetCore.TestBase;
    
    namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo
    {
        public abstract class AbpAspNetCoreMvcUiBootstrapDemoTestBase : AbpAspNetCoreIntegratedTestBase<TestStartup>
        {
            protected override IHostBuilder CreateHostBuilder()
            {
                return base.CreateHostBuilder()
                    .UseContentRoot(CalculateContentRootPath());
            }
    
            private static string CalculateContentRootPath()
            {
                return CalculateContentRootPath(
                    "Volo.Abp.sln",
                    $"test{Path.DirectorySeparatorChar}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo"
                );
            }
    
            private static string CalculateContentRootPath(
                string testFileNameInTheRootFolder,
                string relativeContentPath)
            {
                var currentDirectory = Directory.GetCurrentDirectory();
                while (!ContainsFile(currentDirectory, testFileNameInTheRootFolder))
                {
                    currentDirectory = new DirectoryInfo(currentDirectory).Parent.FullName;
                }
    
                if (!relativeContentPath.IsNullOrWhiteSpace())
                {
                    currentDirectory = Path.Combine(currentDirectory, relativeContentPath);
                }
    
                return currentDirectory;
            }
    
            private static bool ContainsFile(string currentDirectory, string projectFileName)
            {
                return Directory
                    .GetFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly)
                    .Any(f => Path.GetFileName(f) == projectFileName);
            }
    
            protected virtual async Task<string> GetResponseAsStringAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
            {
                using (var response = await GetResponseAsync(url, expectedStatusCode))
                {
                    return await response.Content.ReadAsStringAsync();
                }
            }
    
            protected virtual async Task<HttpResponseMessage> GetResponseAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
            {
                using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, url))
                {
                    requestMessage.Headers.Add("Accept-Language", CultureInfo.CurrentUICulture.Name);
                    var response = await Client.SendAsync(requestMessage);
                    response.StatusCode.ShouldBe(expectedStatusCode);
                    return response;
                }
            }
    
        }
    }
    

    Please return my ticket

    let me know when you have fixed basic-theme template so I can add it to my solution again and test

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://github.com/abpframework/abp/pull/9750

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 18:00