Is the "AutoParameterizationWebConfigConnectionStrings" hole the only way to prevent connection string tokenization?

I'm still trying to figure out MSBuild stuff. I am currently busy with deploying through powershell script using generated scripts from PackageWeb-Nuget-Package ( video ). I tried this for a few days and it seemed to work. But "suddenly" the connection string in the generated web.config file is tokenizable, and instead of the corresponding connection string, I see

connectionString="$(ReplacableToken_DefaultConnection-Web.config Connection String_0) 

I wrote "unexpectedly" because I could not associate this (for me new) behavior with everything that I did in the previous hours.

So, to summarize: deploying from a package works fine, the correct configuration conversion is also applied, but in the end I get this tokenized connection string.

I understand that I can fix this if I insert

 <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings> 

in the PropertyGroup (I just put it in the generated goals file that creates the Nuget-Package)

However, I really do not like this, I need to insert this additional value into each project that may be needed; especially because I did not know that I needed this setting in the first place. This worked yesterday, and I did not have this extra line inserted into any projects or goal files.

So, I was hoping that maybe someone knows an additional switch, trick, or tweak that could have an additional impact on how this works.

+6
source share
3 answers

Microsoft uses automatic parameterization by default. This includes het connectionstrings. You can disable this by adding this to the project file.

<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>

To disable all conversions, you can add this as described here .

<TransformWebConfigEnabled>false</TransformWebConfigEnabled>

Disable all options for the deployment package: <DisableAllVSGeneratedMSDeployParameter>true</DisableAllVSGeneratedMSDeployParameter>

+1
source

I noticed that things like $ (ReplacableToken_ seem to happen by accident when posting and were able to correct the situation by doing a cleanup before rebuilding and republishing. However, since you cannot really know if you always manually check web.config after posting, I also added

 <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings> 

to the web service project in question.

0
source

Now that my company uses the TFS Release Manager tool, which works without a single assembly, we no longer use the web.config transformations and instead use the MS WebDeploy parameters.xml method to replace the values ​​for different environments. However, I ran into the problem of the line "auto-gen'd" mentioned above. Below is one job for him.

If you use parameters.xml files in your project, if you specify your parameter with the same name as for auto-gen'd for your connection string, it works.

So, I have “DBConnectionNameHere” (which will be my example connectionStrings 'name' in web.config), and then I just add "-StringString Connection-String" to the name. Now, instead of the line auto-gen'd conn, which overrides my own in the parameters.xml file, it will work and just add an additional and safe child tag 'parameterEntry'.

For instance:

 <parameter name="DbConnectionNameHere-Web.config Connection String" defaultValue="#{TokenHereOrActualValue}#"> <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DbConnectionNameHere']/@connectionString" /> </parameter> 

Hope this helps someone!

Chris

0
source

Source: https://habr.com/ru/post/945590/


All Articles