如何摆脱"$(ReplacableToken ...)"完全在web.config中 [英] How to get rid of "$(ReplacableToken...)" in web.config completely

查看:121
本文介绍了如何摆脱"$(ReplacableToken ...)"完全在web.config中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个可发布的程序包,当我导航到obj\Debug\Package\PackageTmp目录时,我看到web.config的连接字符串被可替换的令牌替换,而我根本不希望这样做.我将不会使用发布批处理文件或任何东西,而是将文件复制到目录中(我使用发布包系统只是为了摆脱大量动态生成的文件,而我正在测试自己的项目并获得我的项目的新鲜/原始文件树),我不希望这些web.config标记和转换等,我只想像其他任何文件一样复制我的web.config文件.我该如何实现?我已经看到了/p:AutoParameterizationWebConfigConnectionStrings=False命令行的方法,但是我没有使用命令行,而是使用GUI创建程序包.如何阻止web.config将连接字符串更改为令牌?

I am creating a publishable package and when I navigate to obj\Debug\Package\PackageTmp directory, I am seeing the web.config's connection string is replaced by a replacable token, and I simply don't want that. I won't be using publishing batch files or anything, I'll be copying the files in the directory (I'm using the publishing package system only to get rid of lots of dynamically generated files while I'm testing my project and get the fresh/original file tree of my project) I don't want those web.config tokens and transforms etc, I just want my web.config file to be copied just like any other file. How do I achieve that? I've seen the /p:AutoParameterizationWebConfigConnectionStrings=False method for the commad line but I'm not using the command line, I am using the GUI to create the package. How will I stop web.config from changing the connection string to a token?

在您说之前:是的,我知道我可以从原始目录中复制原始的web.config,但是我不想这样处理,我想在单击时完成它正在测试发布程序包,并经常重新创建该程序包.

And before you say: Yes, I know that I can copy the original web.config from my original directory, but I don't want to deal with this and that, I want to finish it with a single click as I'm testing the publish package and frequently re-creating the package.

推荐答案

您必须编辑.csproj文件,并且必须在Debug PropertyGroup中添加以下内容:

You have to edit your .csproj file and in the Debug PropertyGroup you'll have to add the following:

<AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>

我在Project.csproj的 Release ReleaseCERT 配置中具有以下内容(我仅添加了AutoParameterizationWebConfigConnectionStrings行):

I have the following on Release and ReleaseCERT Configurations in my Project.csproj (I've only added the AutoParameterizationWebConfigConnectionStrings line):

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '**Release**|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <!-- add the following line to avoid ConnectionString tokenization -->
    <AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == '**ReleaseCERT**|AnyCPU'">
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <!-- add the following line to avoid ConnectionString tokenization -->
    <AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>
</PropertyGroup>

这篇关于如何摆脱"$(ReplacableToken ...)"完全在web.config中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆