문제

Visual Studio의 devenv 빌드 프로세스 또는 msbuild의 출력에 Vim의 빠른 수정 기능을 사용하고 싶습니다.

다음과 같이 devenv 빌드를 실행하는 build.bat라는 배치 파일을 만들었습니다.

devenv MySln.sln /Build Debug

vim에서는 해당 배치 파일에 :make 명령을 지정했습니다.

:set makeprg=build.bat

이제 :make를 실행하면 빌드가 성공적으로 실행되지만 오류가 구문 분석되지 않습니다.따라서 :cl 또는 :cn을 실행하면 devenv /Build의 모든 출력이 표시됩니다.오류만 보아야 합니다.

나는 인터넷의 다양한 사이트에서 찾은 다양한 오류 형식 설정을 시도했지만 그 중 어느 것도 오류를 올바르게 구문 분석하지 못했습니다.제가 시도한 몇 가지 사항은 다음과 같습니다.

set errorformat=%*\\d>%f(%l)\ :\ %t%[A-z]%#\ %m
set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
set errorformat=%f(%l,%c):\ error\ %n:\ %f

물론 저는 Vim의 기본값을 사용해 보았습니다.

다음은 build.bat의 몇 가지 출력 예입니다.

C:\TFS\KwB Projects\Thingy>devenv Thingy.sln /Build Debug 

Microsoft (R) Visual Studio Version 9.0.30729.1.
Copyright (C) Microsoft Corp. All rights reserved.
------ Build started: Project: Thingy, Configuration: Debug Any CPU ------
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationProvider.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Thingy.exe /resource:obj\Debug\Thingy.g.resources /resource:obj\Debug\Thingy.Properties.Resources.resources /target:winexe App.xaml.cs Controller\FieldFactory.cs Controller\UserInfo.cs Data\ThingGatewaySqlDirect.cs Data\ThingListFetcher.cs Data\UserListFetcher.cs Gui\FieldList.xaml.cs Interfaces\IList.cs Interfaces\IListFetcher.cs Model\ComboBoxField.cs Model\ListValue.cs Model\ThingType.cs Interfaces\IThingGateway.cs Model\Field.cs Model\TextBoxField.cs Model\Thing.cs Gui\MainWindow.xaml.cs Gui\ThingWindow.xaml.cs Interfaces\IField.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs RequiredValidation.cs "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\FieldList.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\MainWindow.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\ThingWindow.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\App.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\GeneratedInternalTypeHelper.g.cs"
C:\TFS\KwB Projects\Thingy\Thingy\Controller\FieldFactory.cs(14,19): error CS0246: The type or namespace name 'IFieldNothing' could not be found (are you missing a using directive or an assembly reference?)

Compile complete -- 1 errors, 0 warnings
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

업데이트:devenv 대신 msbuild를 사용하는 것이 아마도 올바른 방법인 것 같습니다(Jay의 의견에 따르면).

msbuild를 사용하면 makeprg는 다음과 같습니다.

:set makeprg=msbuild\ /nologo\ /v:q

샘플 출력은 다음과 같습니다.

Controller\FieldFactory.cs(14,19): error CS0246: The type or namespace name 'IFieldNothing' could not be found (are you missing a using directive or an assembly reference?)

여기서 까다로운 부분은 경로가 Vim의 현재 디렉터리이고 .csproj 파일 위의 한 디렉터리에 있는 .sln 파일이 아니라 .csproj 파일에 상대적이라는 사실에 있을 수 있습니다.

답변:나는 그것을 알아...

set errorformat=\ %#%f(%l\\\,%c):\ %m

그러면 devenv /Build 및 msbuild에 대한 출력이 캡처됩니다.그러나 msbuild에는 한 가지 문제가 있습니다.기본적으로 출력에는 전체 경로가 포함되지 않습니다.이 문제를 해결하려면 csproj 파일의 기본 PropertyGroup에 다음 줄을 추가해야 합니다.

<GenerateFullPaths>True</GenerateFullPaths>
도움이 되었습니까?

해결책

오류 형식을 포함하여 Vim에서 C# 프로젝트를 빌드하는 방법에 대한 모든 세부 정보를 안내하는 블로그 게시물이 있습니다.여기에서 찾을 수 있습니다: http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html

간단히 말해서 다음이 필요합니다.

:set errorformat=\ %#%f(%l\\\,%c):\ %m
:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true

다른 팁

질문에서 복사하여 '답변 없음' 목록에서 제거

set errorformat=\ %#%f(%l\\\,%c):\ %m

그러면 두 가지 모두에 대한 출력이 캡처됩니다. devenv /Build 그리고 msbuild.그러나 msbuild에는 한 가지 문제가 있습니다.기본적으로 출력에는 전체 경로가 포함되지 않습니다.이 문제를 해결하려면 csproj 파일의 기본 PropertyGroup에 다음 줄을 추가해야 합니다.

<GenerateFullPaths>True</GenerateFullPaths>

더 나은 답변을 찾았습니다.사용 :compiler 내장을 사용하려면 efm 설정.

" Microsoft C#
compiler cs
" Microsoft Visual C++
compiler msvc
" mono
compiler mcs
" gcc
compiler gcc

메모:또한 기본값을 설정합니다. makeprg.$VIMRUNTIME/컴파일러/를 참조하세요.

devenv 대신 msbuild를 실행해 보세요.이렇게 하면 빌드가 실행되는 방식에 엄청난 힘이 생길 것입니다.

Visual Studio 명령 프롬프트를 열어 경로를 설정하세요.그럼 해 msbuild MySln.sln /Configuration:Debug.

보다 msbuild /? 도와주기 위해.

Visual Studio에서 C++를 컴파일하기 위한 오류 형식을 찾을 때 이 질문을 발견했습니다.위의 답변은 나에게 적합하지 않습니다 (나도 MSBuild를 사용하지 않습니다).

나는 이것을 알아 냈다. 이 Vim 팁 그리고 :help errorformat:

" filename(line) : error|warning|fatal error C0000: message
set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m

그러면 다음과 같은 빠른 수정이 제공됩니다.

stats.cpp|604 error 2039| 'getMedian' : is not a member of 'Stats'

(오류가 강조 표시됨)

c:\p4\main\stats.cpp(604) : error C2039: 'getMedian' : is not a member of 'Stats'

Simon Buchan이 언급했듯이 프로젝트에서 이를 사용하여 출력의 전체 경로를 생성할 수 있습니다.

<GenerateFullPaths>True</GenerateFullPaths>

하지만 다음을 추가하면 휴대성을 더욱 높일 수 있습니다. /property:GenerateFullPaths=true 당신에게 makeprg 위의 내용을 프로젝트 파일에 추가하는 대신.

:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true\

이러한 오류 형식은 Visual Studio 2009 v9.0.21022.8 Professional Edition에서 작동하지 않았습니다.cygwin을 사용하면 bash에서 devenv를 호출해야 했고 이로 인해 makeprg 설정이 약간 까다로워졌습니다(나사 배치 파일).또한 devenv가 여러 프로세스로 분할되고 "1>" 또는 "2>" 등의 오류 메시지가 표시될 때 내 오류 형식을 조정해야 했습니다.

set autowrite
"2>c:\cygwin\home\user\proj/blah.cpp(1657) : error C2065: 'blah' : undeclared identifier

set errorformat=%.%#>\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m
let prg="devenv"
let makepath=$MAKEPATH
let &makeprg='cmd /c "'.prg.' '.makepath.'"'

내 .bashrc는 cygpath를 사용하여 MAKEPATH 환경 변수를 설정하여 DOS 호환 경로로 변환합니다.

export MAKEPATH="$(cygpath -d "proj/VC9/some.sln") /build \"Debug\""

vim 6.x가 있으면 사용할 수 있습니다 :cw 이는 clist보다 훨씬 낫습니다(수백 개의 경고 중에서 오류를 검색해 보면 무슨 뜻인지 알 수 있습니다).vim 조정을 보면 토하고 싶지만 vim 천국에 있어요!!!안녕 비주얼 스튜디오!pydave +1을 조정해 주셔서 감사합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top