2

I have added a code piece in my MS build file to run a powershell script. But while building it gives me a error error MSB4067: The element "Exec" beneath element "Project" is unrecognized.

Below is the code:

<PropertyGroup>
  <PowerShellExe Condition=" '$(PowerShellExe)'=='' ">
    %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe
  </PowerShellExe>
  <ScriptLocation Condition=" '$(ScriptLocation)'=='' ">
    D:\Synopsis\SynopsysDetect.ps1
  </ScriptLocation>
  </PropertyGroup>
  <Exec Command="%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -ExecutionPolicy Unrestricted -command ^&quot;^&amp; {^&amp;&apos;D:\Synopsis\SynopsysDetect.ps1&apos;} ^&quot;" />

Not sure if the issue is with code or have I placed the code piece at the wrong place. Any help would be appreciated. Thanks.

2
  • 1
    I think this must be inside a target. Commented Nov 20, 2019 at 8:25
  • 1
    What version of TFS is this for? tfsbuild.proj files were deprecated in TFS 2010, so about ten years ago. If you're still on TFS 2008, you are way, way overdue for an upgrade as that version of TFS, the version of SQL server it runs on, and the OS it runs on are all long past the point of being supported. Commented Nov 20, 2019 at 13:04

2 Answers 2

1

Moving the above piece of code completely into the "Target" tag fixed the issue.

Sign up to request clarification or add additional context in comments.

Comments

0

MSB4067 is "UnrecognizedChildElement". It means that the element containing this line doesn't "know" the exec command. Since the tag </PropertyGroup> is above your line, I have no idea how your structure look like. Please share more of the file blurring confidential parts.

Also see that TFS has a "Run powershell step" that you can use.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.