0

I have a .csproj file with this code:

<Target Name="PrecompileScript" BeforeTargets="BeforeBuild"> <Exec Command="powershell -file $(MSBuildProjectDirectory)\..\..\settings\copy-settings.ps1 $(MSBuildProjectDirectory)" /> </Target>

It should copy setting from one folder to another.

But after building project, I have an error with message

Severity Code Description Project File Line Suppression State Error MSB3073 The command "powershell -file <path> exited with code 1.

If I'm trying to run this script from Windows cmd, it is successful.

How I should run the script from .csproj file?

mrblamber
  • 27
  • 1
  • 6
  • Script: `$projectFolder = $args[0] $settingsFolder = $PSScriptRoot cp $settingsFolder $projectFolder -force -recurse` – mrblamber Apr 20 '17 at 12:34
  • its usually an invalid path or incorrect working directory. have you checked both? as you said from windows cmd it works what about from a a different folder? – Digvijay Apr 20 '17 at 12:37
  • http://stackoverflow.com/questions/25032231/why-do-all-pre-build-or-post-build-events-in-visual-studio-fail-with-exit-code-1 – David Brabant Apr 20 '17 at 12:39
  • @Digvijay paths are correct. Maybe it's because of braces or quotes. But I tried different ways, and didn't get a result. – mrblamber Apr 20 '17 at 12:41
  • maybe the exit 0 as suggested by @David Brabant – Digvijay Apr 20 '17 at 12:44
  • Can you run this command/script successfully from command line? Is script execution enabled? – Pawel Apr 21 '17 at 20:41

0 Answers0