ASP.NET核心Web应用中的多个开发应用程序设置

发布于 2025-02-07 10:12:08 字数 1624 浏览 1 评论 0原文

我对ASP.NET核心Web应用程序和开发环境有一个理解的问题。 有没有办法在开发模式下具有多个应用程序?例如appsettings.development.json and AppSettings.development.linux.json。 问题是AppSettings.development.json保留特定于Windows的设置和AppSettings.development.linux.json保留特定于Linux的设置。如果我输入“ aspnetcore_environment”:“ devel那么,仅在发布版本中存在物理存在。至少这就是我到目前为止理解的方式。 因此,也许有一种方法可以编程和独立于Aspnetcore_environment启用开发模式?还是我做错了什么,我应该做不同的事情吗?

我的启动集。JSON看起来像:

{
    "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
            "applicationUrl": "http://localhost:8691",
            "sslPort": 44311
        }
    },
    "profiles": {
        "Kestrel Dev Blazor": {
            "commandName": "Project",
            "launchBrowser": true,
            "launchUrl": "https://localhost:6501",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "dotnetRunMessages": "true",
            "applicationUrl": "https://localhost:6501;http://localhost:6500"
        },
        "Development.Linux : WSL 2": {
            "commandName": "WSL",
            "launchBrowser": true,
            "launchUrl": "https://localhost:6501",
            "environmentVariables": {
                "ASPNETCORE_URLS": "https://localhost:6501;http://localhost:6500",
                "ASPNETCORE_ENVIRONMENT": "Development.Linux",
                "LD_LIBRARY_PATH": "$LD_LIBRARY_PATH:[PATH_TO_64BIT_LIBS]:[PATH_TO_32BIT_LIBS]",
                "LD_PRELOAD": "[PATH_TO_PRELOAD_LIBS]"
            },
            "distributionName": "Ubuntu"
        }
    }
}

I have an understanding question about ASP.NET Core Web Apps and the development environment.
Is there a way to have multiple appsetings in development mode? For example appsettings.Development.json and appsettings.Development.Linux.json.
The problem is that appsettings.Development.json holds Windows-specific settings and appsettings.Development.Linux.json holds Linux-specific settings. If I enter "ASPNETCORE_ENVIRONMENT": "Development.Linux" in the launchSettings, the development mode no longer works properly and I get error messages that static files can no longer be loaded, e.g. "_content/..." is not found at all, which is only physically exists in the Released Version. At least that's how I understood it until now.
So maybe there is a way to enable development mode programmatically and independently of ASPNETCORE_ENVIRONMENT? Or am I doing something completely wrong and should I proceed differently?

My launchSetting.json looks like:

{
    "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
            "applicationUrl": "http://localhost:8691",
            "sslPort": 44311
        }
    },
    "profiles": {
        "Kestrel Dev Blazor": {
            "commandName": "Project",
            "launchBrowser": true,
            "launchUrl": "https://localhost:6501",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "dotnetRunMessages": "true",
            "applicationUrl": "https://localhost:6501;http://localhost:6500"
        },
        "Development.Linux : WSL 2": {
            "commandName": "WSL",
            "launchBrowser": true,
            "launchUrl": "https://localhost:6501",
            "environmentVariables": {
                "ASPNETCORE_URLS": "https://localhost:6501;http://localhost:6500",
                "ASPNETCORE_ENVIRONMENT": "Development.Linux",
                "LD_LIBRARY_PATH": "$LD_LIBRARY_PATH:[PATH_TO_64BIT_LIBS]:[PATH_TO_32BIT_LIBS]",
                "LD_PRELOAD": "[PATH_TO_PRELOAD_LIBS]"
            },
            "distributionName": "Ubuntu"
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文