为什么Visual Studio中的所有预生成或生成后事件都失败,退出代码为1? [英] Why do all Pre-build or Post-build events in Visual Studio fail with exit code 1?

查看:375
本文介绍了为什么Visual Studio中的所有预生成或生成后事件都失败,退出代码为1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在解决方案A的发布后事件中将.exe文件从解决方案A的bin文件夹复制到另一个解决方案B资源文件夹. 我创建了必要的xcopy命令,并在powershell中对其进行了尝试:它运行完美.
每当我将任何命令添加到VS构建中的操作时,都会失败,并显示以下错误:#command#以代码1退出",其中#command#例如是xcopy命令.
我尝试以管理员身份运行VS,目前我仅尝试运行一个包含"@echo off @exit 0"的.bat文件.这也导致#command#以代码1退出".

有一些我作为VS post/pre-build命令尝试过的示例:
呼叫"projdir \ test.bat"
致电projdir \ test.bat
"projdir \ test.bat"
projdir \ test.bat
...我尝试将projdir用作"$(ProjectPath)"和手动路径.

我将输出置于详细状态,发现以下内容:
命令"C:\ Users \ Traubenfuchs \ AppData \ Local \ Temp"写错或找不到. (该文件夹实际上存在,但我不知道它想要做什么.)
当我在pre/post构建中放置xcopy命令时,也会发生同样的事情.

有人知道我在做什么错吗?

My goal is copying an .exe file from a bin folder of solution A to another solutions B resource folder on the post build event of solution A.
I created the necessary xcopy command and tried it out in powershell: It works perfectly.
Whenever I add any command to the actions in VS build fails with: "#command# exited with code 1", where #command# is, for example, the xcopy command.
I tried running VS as admin and currently I tried just running a .bat file that contains "@echo off @exit 0". That too leads to "#command# exited with code 1".

Have some example of what I tried out as VS post/pre-build command:
call "projdir\test.bat"
call projdir\test.bat
"projdir\test.bat"
projdir\test.bat
... I tried projdir as "$(ProjectPath)" and manual path.

I put output to verbose and found the following:
The command "C:\Users\Traubenfuchs\AppData\Local\Temp" is written incorrectly or couldn't be found. (That folder actually exists but I don't know what it wants to do it.)
The same thing happens when I put an xcopy command in pre/post build.

Anyone knows what I am doing wrong?

推荐答案

最近我遇到了类似的问题.

Recently I met similar problem.

关于您的"hello world"构建后事件: 尝试直接调用powershell

About your "hello world" post-build event : try to call powershell directly

powershell -command "write-output 'hello world'; exit 0"

=================

=================

我的预构建事件如下:

powershell -file scriptPath.ps1

我的scriptPath.ps1看起来像:

My scriptPath.ps1 looks like :

<my epic powershell code>
...
exit 0

请注意,最后没有"exit 0",我从脚本中收到了返回码1.

Note that without "exit 0" at the end I recieved return code 1 from my script.

这篇关于为什么Visual Studio中的所有预生成或生成后事件都失败,退出代码为1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆