我的var f = Builders<BsonDocument>.Filter;
var filter = f.And(f.Eq("Id", ids.ThreadId), f.Eq("Answers.$[].Id", ids.AnswerId));
var projection = Builders<BsonDocument>.Projection.Include("Answers.Likes.$");
var likes = await dbClient.GetCollection<BsonDocument>(nameof(Thread))
.Find(filter)
.Project(projection)
.FirstOrDefaultAsync();
中有这个:
dotnet core 3.1 webapp tasks.json
当我运行 "env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5000",
"LOCAL": "true"
},
时,这是Debug web.config包含的内容:
dotnet publish
因为我想在IIS下托管,所以这是我希望包含的内容,因此,现在我需要手动对其进行编辑:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
运行<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
<environmentVariable name="ASPNETCORE_URLS" value="http://localhost/app" />
<environmentVariable name="LOCAL" value="true" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
时如何配置解决方案或.vscode .json
文件进行更改?
答案 0 :(得分:0)
1)您可以在发布时使用以下命令添加环境变量:
dotnet publish -c Debug -r /p:EnvironmentName=Development
2)在发布配置文件中添加environmnet变量
<PropertyGroup>
<EnvironmentName>Development</EnvironmentName>
</PropertyGroup>
3)修改项目文件(.CsProj)文件
参考链接:
Publish to IIS, setting Environment Variable
how to set ASPNETCORE_ENVIRONMENT to be considered for publishing an asp.net core application?