How to get rid of “$(ReplacableToken…)” in web.config completely

前端 未结 4 1747
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 08:43

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

相关标签:
4条回答
  • 2021-01-30 08:51

    I had to add the following in the Release condition section of my Project.csproj file:

    <InsertAdditionalWebCofigConnectionStrings>False</InsertAdditionalWebCofigConnectionStrings>
    
    0 讨论(0)
  • 2021-01-30 09:00

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

    <AutoParameterizationWebConfigConnectionStrings>False</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>
    
    0 讨论(0)
  • 2021-01-30 09:01

    I had to do what the accepted answer said, but instead in the Properties/PublishProfiles/__THEPROFILE__.pubxml file rather than the .csproj file.

    (this may because I'm using VS2012?)

    0 讨论(0)
  • 2021-01-30 09:02

    I had a similar issue when I was trying to create a web project package externally for a WiX setup according to the Travis Illig instructions. I solved it by adding the AutoParameterizationWebConfigConnectionStrings=False to the MSBuild/@Properties:

    <MSBuild Projects="%(ProjectReference.FullPath)"
             Targets="Package"
             Properties="Configuration=$(Configuration);Platform=AnyCPU;AutoParameterizationWebConfigConnectionStrings=False"
             Condition="'%(ProjectReference.WebProject)'=='True'"
    
    0 讨论(0)
提交回复
热议问题