我有一个解决方案,里面有三个项目都是动态创建的。现在,我必须将第一个项目的引用添加到第二个和第三个项目。当我尝试逻辑时,我可以单独构建项目,而在构建解决方案时,会抛出"Reference could not be loaded properly"
错误。.dll
直接使用theVSProject.References.Add()
方法添加时会发生这种情况。
因此,我尝试使用下面的代码发布到上面,以解决上述问题。但我仍然遇到一些错误。
Imports VSLangProj
' Add the second project as a reference to the first project.
Sub AddProjectExample()
' First project is a Visual Basic or C# project.
Dim theVSProject As VSProject = _
CType(DTE.Solution.Projects.Item(1).Object, VSProject)
' Second project is any type of project.
Dim secondProject As Project = DTE.Solution.Projects.Item(2)
' AddProject returns the newly created Reference object.
Dim newReference As Reference
newReference = theVSProject.References.AddProject(secondProject)
End Sub
错误是
The referenced assembly 'EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be found.
有什么解决办法吗?
我们无权VS IDE
使用以下修复程序的文件夹。
注意:还尝试了以下解决方案进行应用,App.Config
但仍然存在问题。
NWard绝对正确。不确定要用于添加引用的代码,但是可以通过编程方式编辑项目根目录中的csproj文件,以在其适当位置添加以下内容:
<ItemGroup>
<ProjectReference Include="..\MyOtherProj\MyOtherProj.csproj">
<Project>{abda85bb-2019-4b80-982e-b90add3fcca0}</Project>
<Name>MyOtherProj</Name>
</ProjectReference>
</ItemGroup>
调用内部调用的powershell脚本或某些控制台exe。希望这可以帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句