我希望以编程方式更新Visual Studio解决方案中项目中的引用。
I wish to programmatically update the references in the projects in my Visual Studio solution.
我的解决方案中大约有15个项目,在进行开发/调试时,希望引用指向解决方案中的项目。
I have roughly 15 projects in my solution and when I am developing/debugging I want the references to point to the projects within the solution.
作为发布过程的一部分,有时我需要复制一个项目,然后将引用更新为point
As part of my release procedure I sometimes need to make a copy of one project and then update the references to point to built dlls in a certain folder.
我可以计算出项目文件的结构以及引用在其中的工作方式,我正在考虑构建一个命令行工具来解析项目文件并根据需要更改引用。
I can work out the structure of the project files and how references work within them and I am thinking of building a command line tool to parse the project files and change references as required.
我的问题是: 1.这听起来明智吗? 2.有任何人对此有经验,和/或他们如何处理在开发和发布模式之间的切换 3.是否有人拥有处理解析Visual Studio项目文件的库。
My questions are: 1. Does this sound a sensible thing to do 2. Has anyone experience of this and/or how do they handle switching between developing and release modes 3. Does anyone have any libraries that deal with parsing Visual Studio project files.
说明:
感谢您的答复。也许我应该澄清一些我想使用的情况。
Thanks for the responses. Perhaps I should clarify a few situations where I wish to use this.
a)我的应用程序包含15个项目。我尝试使解决方案尽可能小,以适应我的工作,因此说我的解决方案中有5个项目。现在,我需要调试/开发不在解决方案中的项目之一,因此我添加了该项目,但我必须:-将原始项目中的引用设置为指向项目引用,而不是编译的dll -更改新添加的项目中的引用以指向适当的项目引用
a) My application contain 15 projects. I try and keep the solution as small as possible for what I am working on, so say I have 5 projects in my solution. I now need to debug/develop one of the projects not in the solution so I add this project but I have to: - set the references in the original projects to point to project references rather than compiled dlls - change the references in the newly added project to point to the appropriate project references
我希望我的工具自动执行此操作,这是我知道的唯一方法目前正在处理项目文件
I would like my tool to do this automatically and the only way I know to so this at present is manipulating the project files
b)作为Service Pack构建过程的一部分,我复制了一个项目,进行了必要的代码更改并使用Visual构建工作室。为此,我必须更改对已编译dll的所有引用
b) As part of a service pack build procedure I take a copy of one of the projects, make the necessary code changes and build using Visual Studio. To do this I have to change all the references to the compiled dlls
推荐答案我认为对此更好的方法是使用直接在项目文件中引用上的条件块。然后,您需要做的就是在msbuild中为发布版本设置一个特定的标志,它将获取正确的引用。
I think a better approach to this would be to use Conditional blocks on your references inside the project file directly. Then all you need to do is set a particular flag during the msbuild for the "release" build and it will pick up the correct references.
例如
<ItemGroup Condition="'$(IsRelease)'=='True'"> <Reference Include="..." /> </ItemGroup> <ItemGroup Condition="'$(IsRelease)'!='True'"> <Reference Include="..." /> </ItemGroup>更多推荐
以编程方式更新Visual Studio项目引用
发布评论