我的构建:
生成包含以下文件的工件(nuget 包):
cspkg 是一个有效的、可部署的包。问题在于它包含一个预转换的 web.config,因为转换发生在部署时。有关转换和变量替换的信息,请参阅 Octopus 文档以供参考。
如何使用驻留在部署包中的转换后的 web.config 覆盖 cspkg 内的 web.config?
我可以使用 powershell 和完整的 .net 框架。
或者,如果解压 cspkg、覆盖文件然后重新打包更有意义,我认为这是可以接受的。我也不知道该怎么做。
我知道Save-AzureServiceProjectPackage存在,但我无法让它运行并且缺少文档。
msbuild powershell azure octopus-deploy web.config-transform
我不知道我做错了什么,但我几乎觉得我已经尝试了一切.我似乎无法通过web.debug.config更改来获取我的项目的web.config.我在某处读到只有在发布时才进行转换.然后我读到SlowCheetah可以处理这个,所以我把它安装到我的项目中.它也没有任何区别.
运行VS 2012 Express.我使用VS安装的IIS Express本地服务器进行调试.我运行Firefox作为我的浏览器.
web.config中:
<appSettings>
<add key="SiteUrl" value="http://development.mysite.com/" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
web.debug.config:
<appSettings>
<add key="SiteUrl" value="http://localhost:4652/"
xdt:Transform="SetAttributes"
xdt:Locator="Match(key)" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用Replace:
<appSettings>
<add key="SiteUrl" value="http://localhost:4652/"
xdt:Transform="Replace"
xdt:Locator="Match(key)" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
在本地调试配置中运行时:
string siteurl = ConfigurationManager.AppSettings["SiteUrl"];
Run Code Online (Sandbox Code Playgroud)
仍然导致siteurl http://development.mysite.com/
我通过右键单击web.debug.config来运行预览转换,它显示转换完美,但不是我在本地运行Web应用程序时.
不得不承认,我没有看到如何配置SlowCheetah.我没有看到任何配置它的方法,我一直在想也许它本身就有"某些东西".:S
有谁知道如何克服这一点,或者我可能做错了什么?
我正在使用 Visual Studio 2013,有一次我能够右键单击 web.config 转换文件,并且有一个“预览转换”选项,我可以单击该选项并查看文件转换的结果。我所拥有的任何解决方案都不再存在。
我如何才能恢复此选项,或者是进入转换预览的另一种方式?
我最近确实更新到了 Update 3。
如何在Azure Web应用程序中更改applicationHost.config?我尝试:
using (ServerManager serverManager = new ServerManager())
{
Microsoft.Web.Administration.Configuration config = serverManager.GetApplicationHostConfiguration();
Microsoft.Web.Administration.ConfigurationSection webLimitsSection = config.GetSection("system.applicationHost/webLimits");
webLimitsSection["connectionTimeout"] = TimeSpan.Parse("00:00:10");
webLimitsSection["dynamicIdleThreshold"] = 150;
webLimitsSection["headerWaitTimeout"] = TimeSpan.Parse("00:00:10");
webLimitsSection["minBytesPerSecond"] = 500;
serverManager.CommitChanges();
}
Run Code Online (Sandbox Code Playgroud)
但抓住异常:
文件名:\?\ D:\ Windows\system32\inetsrv\config\applicationHost.config错误:由于权限不足,无法写入配置文件
我想知道如何自动更改我的应用程序的连接字符串,所以当我在我的电脑上处理它时,它使用我的本地 SQL Server,一旦我发布它,然后使用我在 azure 上托管的 SQL Server。
现在我只是根据我想要的内容注释掉连接字符串,我看到 Web.Config 文件有 2 个依赖项,Web.Debug.config 和 Web.Release.config,我想我必须做些什么但我不知道是什么。
到目前为止,这是我的 web.config 文件
<connectionStrings>
<add name="MyApp" connectionString="Data Source=mydb.database.windows.net;Initial Catalog=MyDb;User ID=MyUser@mydb.database.windows.net;Password=MyPwd;Encrypt=true;Trusted_Connection=false;" providerName="System.Data.SqlClient" />
<!--<add name="MyApp" providerName="System.Data.SqlClient" connectionString="Server=.\SQLEXPRESS;Database=MyDb;Integrated Security=True;" />-->
</connectionStrings
Run Code Online (Sandbox Code Playgroud)
如您所见,我已注释掉了 2 个连接字符串,但这样做真的很烦人。
我正在创建一个将使用 webApi 的 Angular2 应用程序。处理配置数据的最佳实践是什么?我想要一种在部署到不同环境时进行转换的方法。
在本地工作时,webApi 将是本地的,例如:http://localhost:64551/Api/person。
在开发中,它将是: http: //devServer.com/Api/person
产品将是: http: //prodServer.com/Api/person
我无法对服务器名称进行硬编码。我在配置中需要它,但当我们部署到不同的环境时它会发生变化。
这是我使用 Visual Studio 在 ASP.net 5 项目中构建的 Anglar2 项目。WebApi 是一个 ASP.net 5 项目。我将在 Azure 托管。
过去,我使用过 web.config 转换,但这不是 Angular 应用程序的选项。
有什么建议吗?
Web.config 文件在不同的环境(例如 DEV、QA、Prod)中进行本地转换。在 VSTS 上的不同环境(DEV、QA、Prod)上发布应用程序时,如何使用这些环境特定的配置文件。
我有 web.config 和这两个我需要删除的环境变量,请参见下面的 web.config ..
web.config
<aspNetCore processPath=".\Widgets.API.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
<environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用删除这些变量
web.Release.config
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location>
<system.webServer>
<aspNetCore>
<!--remove the environment vars section in Release mode-->
<!--
Why? Because .NET Core has a bug where it adds environmentVariables section
during the build with the environment set as Development..
This obviously fails in production, which is why we remove it during
release.
-->
<environmentVariable name="COMPLUS_ForceENC" value="1" …Run Code Online (Sandbox Code Playgroud) 我知道,在 Azure DevOps 中创建发布管道时,您可以使用管道中的变量更新应用程序的 web.config,这对于所有 appSettings 值都非常有效。
但是,在发布管道期间,我想更新 web.config 的不同部分,特别是sessionState提供程序节点。我已经尝试了一些用于发布管道的插件,例如 Magic Chunks 的 Config Transform,但问题是它需要您指定要编辑的配置文件的路径,但是当它到达发布管道时,源文件位于zip 存档。不知何故,appSettings 的正常转换能够处理解压版本,但在文件解压后我无法进行其他转换。
我知道您可以在构建管道中进行更改,但我们有理由希望在发布管道中进行更改。
有人知道如何在 Azure 应用服务的发布管道中的 appSettings 分组之外对 web.config 进行更改吗?
web-config web.config-transform azure-devops azure-pipelines azure-pipelines-release-pipeline
我的 ASP.net 应用程序有带有此 appSettings 键的 web.config。
<add key="XmlTag" value="Test"/>
Run Code Online (Sandbox Code Playgroud)
我想要转换的值有“大于”符号,即
<add key="XmlTag" value=">~NewValue" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
Run Code Online (Sandbox Code Playgroud)
当值被转换时,它会将值转换为
<add key="XmlTag" value=">~NewValue"/>
Run Code Online (Sandbox Code Playgroud)
如果我在 web.config 中转义“大于”符号,情况也是如此。
<add key="XmlTag" value=">~NewValue" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
Run Code Online (Sandbox Code Playgroud)
以下是在 Visual Studio 中使用 SlowCheetah 进行的转换预览。
网页配置
变换预览:
我应该在转换配置文件中做什么,以便在转换文件时添加“大于”符号?
azure ×4
azure-devops ×2
c# ×2
web-config ×2
.net ×1
angular ×1
asp.net ×1
asp.net-core ×1
azure-pipelines-release-pipeline ×1
iis ×1
msbuild ×1
powershell ×1
xml ×1
xslt ×1