Failed to encrypt destination web.config when usin

2019-08-03 22:32发布

问题:

I am trying to setup Jenkins to build and deploy my ASP.net MVC project.

My Command Line Arguments are

/p:Configuration=Staging  
/p:DeployOnBuild=true  
/p:PublishProfile=Staging  
/p:ExcludeApp_Data=False  
/p:AllowUntrustedCertificate=True  
/p:LastUsedPlatform="Any CPU"  
/p:MSDeployPublishMethod=WMSVC  
/p:DeployIisAppPath=User Information Portal;  
/p:MsDeployServiceUrl=x.x.x.x  
/p:MSDeployEnableWebConfigEncryptRule=False  
/p:username=x  
/p:password=xx

When Jenkins runs the project it always fails with an error

msdeploy error ERROR_FAILED_TO_ENCRYPT_WEB_CONFIG: Web deployment task failed. (Failed to encrypt destination web.config: C:\Jenkins\jobs\xxxx\workspace\xx\obj\Staging\Package\PackageTmp\Views\Web.config. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FAILED_TO_ENCRYPT_WEB_CONFIG.)

I can do the deployment from Visual Studio but with same arguments Jenkins is not working.

One more question I use entity framework code first approach. Do I need to do anything in Jenkins to run the migration scripts.

If I do MSDeployPublishMethod as FileSystem it is deploying but migration scripts are not running.

Thanks

回答1:

Later I found that my publish profile had /p:MSDeployEnableWebConfigEncryptRule=True.

MS build ignored the command line argument.