code

포스트 빌드가 코드 1로 종료되었습니다.

codestyles 2020. 8. 14. 07:45
반응형

포스트 빌드가 코드 1로 종료되었습니다.


빌드 후 이벤트가있는 프로젝트가 있습니다.

copy $(ProjectDir)DbVerse\Lunaverse.DbVerse.*.exe  $(TargetDir)

내 컴퓨터에서 매번 잘 작동합니다. 항상 "코드 1로 종료"오류가 발생하는 새 개발자가 있습니다. 나는 그녀에게 DOS 프롬프트에서 동일한 명령을 실행하게했고 잘 작동했습니다. 원인은 무엇입니까? 실제 오류에 도달하는 방법이 있습니까?

우리는 둘 다 Visual Studio 2008을 사용하고 있습니다.


경로의 폴더 이름 중 하나에 공백이 있었고 그 주위에 따옴표가 없었습니다.


"핑"이있는 사람이 저를 도왔습니다 ... 그러나 조금 더 잘 설명 될 수 있습니다 ...

저에게 해결책은 다음과 같습니다.

copy $(TargetDir)$(TargetName).* $(SolutionDir)bin

이에:

copy "$(TargetDir)$(TargetName).*" "$(SolutionDir)bin"

그것이 당신을 위해 작동하기를 바랍니다. :-)


코드 1의 이유는 대상 폴더가 읽기 전용 이었기 때문입니다. 이것이 누군가를 돕기를 바랍니다! 한 디렉토리에서 다른 디렉토리로 복사하는 포스트 빌드 이벤트가 있었고 대상은 읽기 전용이었습니다. 그래서 방금 디렉토리와 모든 하위 디렉토리에서 읽기 전용 속성을 선택 취소했습니다! 안전한 디렉토리인지 확인하십시오!


이것은 꽤 활발한 질문이기 때문에 미래의 방문객을 위해 이것을 추가했습니다.

ROBOCOPY는 8 미만의 "성공 코드"로 종료됩니다. 참조 : http://support.microsoft.com/kb/954404

이는 다음을 의미합니다.

robocopy exit code 0 = no files copied
robocopy exit code 1 = files copied
When the result is 1, this becomes an error exit code in visual studio.

그래서 이것을 배치 파일의 맨 아래에 추가하여 쉽게 해결했습니다.

exit 0

이러한 방식으로 ROBOCOPY 오류를 처리하도록 제안

rem each robocopy statement and then underneath have the error check.
if %ERRORLEVEL% GEQ 8 goto failed

rem end of batch file
GOTO success

:failed
rem do not pause as it will pause msbuild.
exit 1

:success
exit 0    

파일이 복사되지 않으면 혼란이 설정됩니다 = VS에 오류가 없습니다. 그런 다음 변경 사항이 있으면 파일이 복사되고 VS 오류가 발생하지만 개발자가 원하는 모든 작업이 수행되었습니다.

추가 팁 : 스크립트에서 일시 중지는 VS 빌드에서 무기한 일시 중지가 될 수 있으므로 사용하지 마십시오. 스크립트를 개발하는 동안 timeout 10. 매달린 빌드가 아니라 이것을 눈치 채고 주석 처리 할 것입니다.


가져 오기 시스 인 터널로부터 프로세스 모니터를 연산 결과 봐 (경로 필드에)에 Lunaverse.DbVerse에 대한보고를 설정합니다. 거기에서 무엇이 잘못되었는지 분명해야합니다.


OS로 보호 된 ".. \ Common7 \ IDE \ PrivateAssemblies"가 작동하도록 빌드 후 복사본을 가져 오려면 VS를 관리자 권한으로 실행해야했습니다.


'사용하는 사람들의 경우, 사본 에'명령을 빌드 이벤트 ( 사전 빌드 이벤트 명령 줄 또는 / 및 빌드 후 이벤트 명령 줄 에서) 프로젝트 -> 속성 : 당신은 ' 복사 '명령 매개 변수는 여기에 같이 나타납니다 copy "source of files" "destination for files". 따옴표를 사용하는 것을 잊지 마십시오 (주소 문자열의 공백 문제를 방지하기 위해).


비슷한 문제가 있었지만 특히 Jenkins 빌드 환경에서 발생했습니다. 이 문제를 해결하기 위해 빌드 후 이벤트에서 복사 명령 사용에서 복사 대상 사용으로 전환했습니다.

나는 이것을 바꿨다.

   <PropertyGroup>
      <PostBuildEvent>copy $(ProjectDir)bin\BLAH.Common.xml $(ProjectDir)App_Data\BLAH.Common.xml</PostBuildEvent>
   </PropertyGroup>

이에:

  <Target Name="AfterBuild">
    <Copy SourceFiles="$(ProjectDir)bin\BLAH.Common.xml" DestinationFolder="$(ProjectDir)App_Data\" />
  </Target>

이제 잘 작동합니다.

내가 얻은 특정 오류는 다음과 같습니다.

(PostBuildEvent target) -> 
  C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(4291,5): error MSB3073: The command "copy <http://1.2.3.4/job/BLAHv2/ws/Api/bin/BLAH.Common.xml> <http://1.2.3.4/job/BLAHv2/ws/Api/App_Data/BLAH.Common.xml"> exited with code 1. [<http://1.2.3.4/job/BLAHv2/ws/Api/Api.csproj]>

I was able to fix my Code 1 by running Visual Studio as Admin. Apparently it didn't have access to execute the shell commands without Admin.


As a matter of good practice I suggest you replace the post build event with a MS Build File Copy task.


For me I had to make sure the the program I was coping file to was not running at the time. There weren't any errors in the syntax. Hope this helps someone.


I just received the same error. I had a % in the destination path that needed to be escaped

c:\projects\%NotAnEnvironmentVariable%

needed to be

c:\projects\%%NotAnEnvironmentVariable%%

Ok, this is a problem with many solutions, so I just post mine to give people more hints. My situation is to double check the folders in your path and make sure all of them exist in your machine. For example: "$(SolutionDir)\partBin\Bin\$(ProjectName).pdb", but "Bin" is not in partBin folder.


For those, who use 'copy' command in Build Events (Pre-build event command line or/and Post-build event command line) from Project -> Properties: target folder should exist


So many solutions...

In my case, I had to save the bat file with non-unicode (Western, Windows) encoding. By default when I added the file to visual studio (and probably I should have done it outside of the VS), it added with UTF-8 encoding.


I had this same issue and it turned out that it was because I had renamed the project. I went into the project properties and changed the Assembly Name and Root Namespace to the project name and it worked great after that!


Yet another answer ...

In my case I had a Visual Studio 2017 project targeting both .Net Standard 1.3 and .Net Framework 2.0. This was specified in the .csproj file like this:

<TargetFrameworks>netstandard1.3;net20</TargetFrameworks>

I also had a post-build event command line like this:

copy "E:\Yacks\YacksCore\YacksCore\bin\net20\Merlinia.YacksCore.dll" "E:\Merlinia\Trunk-Debug\Shared Bin\"

In other words I was trying to copy the .Net Framework .dll produced by the build to an alternative location.

This was failing with this error when I did a Rebuild:

MSB3073 The command "copy "E:\Yacks\YacksCore\YacksCore\bin\net20\Merlinia.YacksCore.dll" "E:\Merlinia\Trunk-Debug\Shared Bin\"" exited with code 1.

After much frustration I finally determined that what was happening was that Rebuild deleted all of the output files, then did the build for .Net Standard 1.3, then tried to run the post-build event command line, which failed because the file to be copied wasn't built yet.

So the solution was to change the order of building, i.e., build for .Net Framework 2.0 first, then for .Net Standard 1.3.

<TargetFrameworks>net20;netstandard1.3</TargetFrameworks>

This now works, with the minor glitch that the post-build event command line is being run twice, so the file is copied twice.


In my case I had to cd (change directory) before calling the bat file, because inside the bat file was a copy operation that specified relative paths.

:: Copy file
cd "$(ProjectDir)files\build_scripts\"
call "copy.bat"

참고URL : https://stackoverflow.com/questions/310126/post-build-exited-with-code-1

반응형