Web Deploy / Publish is adding a unknown connection string?

前端 未结 4 1260
小蘑菇
小蘑菇 2021-01-07 19:09

Previously publishing my web api app was working perfectly. Today i converted my app from being \"any cpu\" to x86. Now when i\'m publishing its adding a connection string t

相关标签:
4条回答
  • 2021-01-07 19:33

    Edit project .csproj file and add this:

    <PropertyGroup>
    <InsertAdditionalWebCofigConnectionStrings>false</InsertAdditionalWebCofigConnectionStrings>
    

    It worked for me.

    0 讨论(0)
  • 2021-01-07 19:39

    The solution that worked for me, although it's more of a hack, was using the web deploy transformations to remove rogue connection string. See user2395249 answer:

    One-click publish in vs 2012: how to remove _ConnectionStringsToInsert?

    0 讨论(0)
  • 2021-01-07 19:42

    In the .pubxml file there where some extra connectionstrings added for some reason. Remove all of them and it should work fine, the default connectionstring will still be added.

    I have a hunch that this has been added to the .pubxml when I fiddled a little with my publishing information but it wasn't removed when I switched back to my regular publish setup.

    <ItemGroup>
        <MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
        <MSDeployParameterValue Include="$(DeployParameterPrefix)MyProject-Web.config Connection String" />
        <MSDeployParameterValue Include="$(DeployParameterPrefix)MyProject_dev-Web.config Connection String" />
      </ItemGroup>
      <ItemGroup>
        <_ConnectionStringsToInsert Include="MyProject" />
        <_ConnectionStringsToInsert Include="Myproject_dev" />
      </ItemGroup>
    
    0 讨论(0)
  • 2021-01-07 19:57

    Add this project property to the .csproj file by editing the XML:

    <Project>
      <PropertyGroup>
    
        <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
    
        ...
      </PropertyGroup>
      ...
    </Project>
    

    Alternatively, use a Web Publishing Pipeline targets file as described in this related StackOverflow question.

    0 讨论(0)
提交回复
热议问题