我有一个构建脚本,它通过Visual Studio 2015,Powershell和devenv.com在解决方案Web.sln中构建项目Web.Auth:
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Devenv.com" /build Debug /Project Web.Auth "C:\Sources\Releases\Web.sln"
当我们使用TFS版本控制时,它工作正常。但在转移到git之后,问题出现了2个错误之一:
如果从命令行构建单个项目或重命名.git文件夹并运行脚本
Package' TestWindowPackage'无法加载。
项目构建但在此错误之后。
或
如果通过脚本和相同的命令构建多个项目
尝试读取或写入受保护的内存
如果我只是简单地重命名.git文件夹,然后构建 - 一切都变好了。 通过Visual Studio 2015 IDE,它可以毫无问题地构建。仅出现控制台脚本问题。
如何解决?
每次构建脚本重命名 .git 文件夹并不是一个好的解决方案。删除index.lock文件并不重命名.git文件夹中的每个文件。只有整个文件夹重命名才有帮助。
堆栈错误(尝试读取或写入受保护的内存):
Devenv.com :
At C:\Sources\Releases\BuildScripts\BuildEnv\buildProjects.ps1:216 char:25
+ ... solResult = & "$VSPath\Devenv.com" $projectConfigPrefix $buildComman ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Unhandled Exception:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at EnvDTE.Commands.Item(Object index, Int32 ID)
at Microsoft.Internal.VisualStudio.Shell.KeyBindingHelper.GetKeyBinding(Guid commandGroup, Int32 commandId, Guid keyBindingScope)
at Microsoft.Internal.VisualStudio.Shell.KeyBindingHelper.GetGlobalKeyBinding(Guid commandGroup, Int32 commandId)
at Microsoft.VisualStudio.PlatformUI.Packages.Scc.KeyBindingProvider.GetKeyBinding(Guid commandSet, Int32 commandId)
at Microsoft.VisualStudio.Services.SccDisplayInformationService.get_PublishKeyBindingText()
at Microsoft.VisualStudio.Services.SccDisplayInformationService.InitializeUI()
at Microsoft.VisualStudio.Services.SccDisplayInformationService.Initialize(IServiceProvider serviceProvider, JoinableTaskFactory joinableTaskFactory, CancellationToken cancella
tionToken, ISccDisplayInformationTelemetryLogger telemetryLogger, INotifySolutionLoadCount notifySolutionLoadCount, ITippingInfoProvider tippingInfoProvider, IKeyBindingProvider k
eyBindingProvider)
at Microsoft.VisualStudio.Services.SccDisplayInformationPackage.InitializeAsync(CancellationToken cancellationToken, IProgress`1 progress)
at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass16_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass16_0.<Microsoft.VisualStudio.Shell.Interop.IAsyncLoadablePackageInitialize.Initialize>b__1(CancellationToken token
)
at Microsoft.VisualStudio.Shell.VsTaskLibraryHelper.<>c__DisplayClass23_0`1.<RunAsyncAsVsTask>b__0()
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.RunAsync[T](Func`1 asyncMethod, Boolean synchronouslyBlocking, JoinableTaskCreationOptions creationOptions)
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.RunAsync[T](Func`1 asyncMethod)
at Microsoft.VisualStudio.Shell.VsTaskLibraryHelper.RunAsync[T](JoinableTaskFactory joinableTaskFactory, VsTaskRunContext priority, Func`1 asyncMethod)
at Microsoft.VisualStudio.Shell.VsTaskLibraryHelper.RunAsyncAsVsTask[T](JoinableTaskFactory joinableTaskFactory, VsTaskRunContext priority, Func`2 asyncMethod)
at Microsoft.VisualStudio.Shell.AsyncPackage.Microsoft.VisualStudio.Shell.Interop.IAsyncLoadablePackageInitialize.Initialize(IAsyncServiceProvider asyncServiceProvider, IProffe
rAsyncService profferAsyncService, IAsyncProgressCallback progressCallback)
at Microsoft.Internal.VisualStudio.Shell.Interop.IVsPackageManagerPrivate.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.<LoadServicePackage>d__17.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.LoadServicePackage(Guid guidService, Boolean loadPackageSynchronously)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.<GetAsyncServiceByGuidThrowing>d__14.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.GetAsyncServiceByGuidThrowing(Guid serviceGuid, Boolean loadPackageSynchronously)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.<>c__DisplayClass9_0.<<Microsoft-VisualStudio-OLE-Interop-IServiceProvider-QueryService>b__0>d.MoveNex
t()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.<>c__DisplayClass9_0.<Microsoft.VisualStudio.OLE.Interop.IServiceProvider.QueryService>b__0()
at Microsoft.VisualStudio.Th
reading.JoinableTaskFactory.RunAsync(Func`1 asyncMethod, Boolean synchronouslyBlocking, JoinableTaskCreationOptions creationOptions, Delegate entrypointOverride)
at Microsoft.VisualStudio.Services.AsyncQueryService.AsyncServiceProvider.Microsoft.VisualStudio.OLE.Interop.IServiceProvider.QueryService(Guid& guidService, Guid& riid, IntPtr
& ppvObject)
at Microsoft.VisualStudio.OLE.Interop.IServiceProvider.QueryService(Guid& guidService, Guid& riid, IntPtr& ppvObject)
at Microsoft.VisualStudio.Shell.ServiceProvider.QueryService(Guid guid, Type serviceType, Boolean setShellErrorInfo, Object& service)
at Microsoft.VisualStudio.Shell.ServiceProvider.GetService(Type serviceType, Boolean setShellErrorInfo)
at Microsoft.VisualStudio.Shell.Package.GetService(Type serviceType)
at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType)
at Microsoft.TeamFoundation.Git.Provider.ServiceProviderExtensionMethods.GetService[T,V](IServiceProvider serviceProvider)
at Microsoft.TeamFoundation.Git.Provider.SccProviderPackage.Initialize()
at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)
或:
Devenv.com :
At line:1 char:1
+ & "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\De ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Microsoft Visual Studio 2015 Version 14.0.25420.1.
Copyright (C) Microsoft Corp. All rights reserved.
Package 'TestWindowPackage' failed to load.
Package 'TestWindowPackage' failed to load.
Package 'TestWindowPackage' failed to load.
Package 'TestWindowPackage' failed to load.
Package 'TestWindowPackage' failed to load.
答案 0 :(得分:1)
在我们的构建计算机上运行Fortify扫描(通过命令行作为Visual Studio 2017的插件运行的静态分析工具)时,我遇到了类似的问题。我遇到了与上述相同的错误:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
当然,重命名.git文件夹可以解决此问题。同样,我们刚刚将解决方案移至新的git repo。
最终的解决方法是从解决方案文件中删除以下部分:
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 3
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = ...
...
EndGlobalSection
我还从解决方案中删除了.vssscc和.vspscc文件。通过这些更改,Fortify能够进行扫描而不会出错。