microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.49k stars 2.61k forks source link

Different issue points when using FileTransform@2 #11856

Closed AllanMichaelsen closed 4 years ago

AllanMichaelsen commented 4 years ago

Question, Bug, or Feature? Type: Bug

Enter Task Name: FileTransform@2

Environment Server - Azure Pipelines

Issue Description When using FileTransform@2 to tranform config files after build we are experiencing some weird behaviour...

If we run the above pipeline with the same two inputfiles, we get different errors on each run. Some runs it finishes an action at a point where it failed in the previous run.

The pipeline step ` steps:

Task logs Executing SetAttributes (transform line 41, 164) System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Web.XmlTransform.XmlTransformationLogger.ConvertUriToFileName(XmlDocument xmlDocument) at Microsoft.Web.XmlTransform.XmlTransformationLogger.LogWarning(XmlNode referenceNode, String message, Object[] messageArgs) at Microsoft.Web.XmlTransform.Transform.ApplyOnAllTargetNodes() Exception while transforming: System.NotSupportedException: The given path's format is not supported. at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) at OutcoldSolutions.ConfigTransformationTool.TransformationTask.Execute(String destinationFilePath, Boolean forceParametersTask). on /configuration/securityConfiguration/authorizationProviders/add/rules/add[@name='AnsoegningRKI_Gem'] Applying to 'add' element (no source line info) Set 'name' attribute Set 'expression' attribute Set 2 attributes Done executing SetAttributes Executing SetAttributes (transform line 42, 177) on /configuration/securityConfiguration/authorizationProviders/add/rules/add[@name='AnsoegningRKI_CheckFirmaRKIGem']


Set 'expression' attribute System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Web.XmlTransform.XmlTransformationLogger.ConvertUriToFileName(XmlDocument xmlDocument) at Microsoft.Web.XmlTransform.XmlTransformationLogger.LogWarning(XmlNode referenceNode, String message, Object[] messageArgs) at Microsoft.Web.XmlTransform.Transform.ApplyOnAllTargetNodes() Exception while transforming: System.NotSupportedException: The given path's format is not supported. at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) at OutcoldSolutions.ConfigTransformationTool.TransformationTask.Execute(String destinationFilePath, Boolean forceParametersTask). Set 2 attributes Done executing SetAttributes Executing SetAttributes (transform line 38, 165) on /configuration/securityConfiguration/authorizationProviders/add/rules/add[@name='AnsoegningRKI_Hent']

If we run the same two files through this powershell it works as expected (as it does in Visual Studio build as well)

`function applyConfigTransformation($src,$xdt,$dst){ Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.XmlTransform.dll"

try{ $doc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument $doc.PreserveWhiteSpace = $true $doc.Load($src)

$trn = New-Object Microsoft.Web.XmlTransform.XmlTransformation($xdt)
if ($trn.Apply($doc)){
  $doc.Save($dst)
}
else{
  throw "Transformation terminated with status False"
}

} catch{ Write-Output $Error[0].Exception } }`

eaarora-ms commented 4 years ago

@AllanMichaelsen Can you please set the variable "System.debug" with value "true". Redeploy and share logs at RM_Customer_Queries at microsoft dot com

eaarora-ms commented 4 years ago

@AllanMichaelsen Can you please confirm if you're still facing the issue? I haven't received any logs from you until now. Thanks!

AllanMichaelsen commented 4 years ago

Sorry for the late reply. A decision was made to transform in the project file instead as there was no time to wait for a solution. If no one else is experiencing this issue it could be a problem in the file structure somehow but I can't say for sure.

I can't send further logs as transformation in this manner has been stopped.


From: Eavanshi Arora notifications@github.com Sent: Wednesday, December 18, 2019 8:41:31 AM To: microsoft/azure-pipelines-tasks azure-pipelines-tasks@noreply.github.com Cc: Allan Michaelsen allan.michaelsen@michaelsenconsult.dk; Mention mention@noreply.github.com Subject: Re: [microsoft/azure-pipelines-tasks] Different issue points when using FileTransform@2 (#11856)

@AllanMichaelsenhttps://github.com/AllanMichaelsen Can you please confirm if you're still facing the issue? I haven't received any logs from you until now. Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/azure-pipelines-tasks/issues/11856?email_source=notifications&email_token=AKCYMKHH4GMEFM6ZVZWNSITQZHH2XA5CNFSM4JSQG4OKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHFHFNI#issuecomment-566915765, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKCYMKHQRHW4BT2U2363Q2TQZHH2XANCNFSM4JSQG4OA.

eaarora-ms commented 4 years ago

Closing this in that case. Please comment if you face the issue again in the future.