Q:

Azure devops pipeline Initialize Job Failing with the error message " #[error]bad content type "

We have Azure-DevOps on premises. 
My Build pipeline was working perfectly also with SonarQube tasks. 
then suddenly I got an error for some access issue for file "Access to the path_work\1\a\MyProject. API.dll. RoslynCA.json" is denied". 
And I have deleted that file with the mindset that if this is the auto-generated file, will get this again.  But no luck and the same error occurred. 
I have removed folder "sonarqubePrepare" and started facing another error -
Error - "Bad content type". ( Note- this error is coming only when I execute sonarqube task, MSBUILD task is working fine)
I have reInstall agent and tried to execute the pipeline again.  but the same issue is there now id "##[error]Bad content type". 
Note-SonarQube task is working fine with some other project on some other build machine. 
Logs-
2019-06-10T13:03:01.22402Z ##[section]Starting: Initialize job

2019-06-10T13:03:01.22572Z Current agent version: '2.141.1'

2019-06-10T13:03:01.238990Z ##[debug]Primary repository: MyRepo. 

 repository type: Tfvc

2019-06-10T13:03:01.249208Z Prepare build directory. 

2019-06-10T13:03:01.28078Z ##[debug]Delete existing artifacts directory: 'E:\vsts-agent-win-x64-2.141.1\_work\1\a'

2019-06-10T13:03:01.280467Z ##[debug]Deleting artifacts directory: 'E:\vsts-agent-win-x64-2.141.1\_work\1\a'

2019-06-10T13:03:01.282948Z ##[debug]Creating artifacts directory: 'E:\vsts-agent-win-x64-2.141.1\_work\1\a'

2019-06-10T13:03:01.283370Z ##[debug]Delete existing test results directory: 'E:\vsts-agent-win-x64-2.141.1\_work\1\TestResults'

2019-06-10T13:03:01.283321Z ##[debug]Deleting test results directory: 'E:\vsts-agent-win-x64-2.141.1\_work\1\TestResults'

2019-06-10T13:03:01.283687Z ##[debug]Creating test results directory: 'E:\vsts-agent-win-x64-2.141.1\_work\1\TestResults'

2019-06-10T13:03:01.2841036Z Set build variables. 

2019-06-10T13:03:01.290128Z Download all required tasks. 

2019-06-10T13:03:01.35085Z Downloading task: SonarQubePrepare

2019-06-10T13:03:01.61385Z ##[error]bad content type

2019-06-10T13:03:01.61594Z ##[debug]System. Exception: bad content type

at Microsoft. TeamFoundation. DistributedTask. WebApi. TaskAgentHttpClient. GetTaskContentZipAsync(Guid taskId, TaskVersion version, Object userState, CancellationToken cancellationToken)

at Microsoft. VisualStudio. Services. Agent. Worker. TaskManager. DownloadAsync(IExecutionContext executionContext, TaskStepDefinitionReference task)

at Microsoft. VisualStudio. Services. Agent. Worker. TaskManager. DownloadAsync(IExecutionContext executionContext, IEnumerable`1 steps)

at Microsoft. VisualStudio. Services. Agent. Worker. JobExtension. InitializeJob(IExecutionContext jobContext, AgentJobRequestMessage message)
2019-06-10T13:03:01.6162764Z ##[section]Finishing: Initialize job

A:

Taking your second error first since that is preventing you reproducing the original error:
By ...

I have removed folder "sonarqubePrepare"

... do you mean you deleted the task folder from the build agent i.e. a folder named something like 
C:\agents\myagent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157? 
If so, this isn't an error with SonarQube Prepare task itself.  You've corrupted the configuration of your build agent by deleting the task folder, and the build agent itself is throwing an error when it tries to ensure that the correct task files are present on the agent.  FYI that folder does not hold any temporary, build-specific files - it holds only the static files that implement the task logic. 
Try reinstalling the build agent in a separate folder on your build agent.