可以通过批处理文件以编程方式删除并添加对csproj的引用? [英] Possible to remove and add a reference to csproj programmatically via a batch file?
问题描述
我的文件夹结构是
/ Build
/ SDK
/ WPF
/4.0:ControlLibrary.dll坐在这里
/示例
/ WPF
/4.0:Examples.csproj坐在这里
假设批处理文件位于/ Build级别,有没有办法修改Examples.csproj来引用ControlLibrary.dll? p>
只是为了澄清,我有这样的结构的原因是我希望部署一个示例csproj与我的控制库一起发货。 examples.csproj应该引用SDK /下的混淆控制库。 examples.csproj也存在于dev trunk(已从其中复制)中,而在开发解决方案中,它以非混淆形式引用ControlLibrary.csproj的输出。
im创建这里是一个文件夹结构来压缩和运送ControlLibrary加上示例,因此需要更新引用。
更新 - 使用Powershell解决
请参阅添加和删除参考资料中的相关问题和答案使用Powershell
csproj
文件是XML文件 - 您可以轻松地编写一个命令行应用程序来处理这些文件(添加,删除节点等)。
您可以从批处理文件中调用这样一个命令行应用程序。 p>
您可以在以下位置找到此文件的架构:
%windir% \Microsoft.NET\Framework\ [框架版本] \Microsoft.Build.xsd
如这样的答案。
I am writing a short batch file to prepare a control library DLL with Examples project for deployment via sip file and have the following question.
Given a csproj file at known location and a DLL at known location, is it possible to programmatically update the csproj from the batch file (via third party command line exe, or other scripting) to add the new DLL?
My folder structure is
/Build
/SDK
/WPF
/4.0 : ControlLibrary.dll sits here
/Examples
/WPF
/4.0 : Examples.csproj sits here
Assuming the batch file is at the /Build level, is there any way to modify Examples.csproj to reference ControlLibrary.dll ?
Just to clarify, the reason why I have the structure like this is I wish to deploy an examples csproj to ship with my control library. Examples.csproj should reference the obfuscated control library under SDK/. Examples.csproj also exists on dev trunk (where it has been copied from) and in the development solution it references output of ControlLibrary.csproj on non obfuscated form.
Essentially what im creating here is a folder structure to zip up and ship the ControlLibrary plus examples, hence, the need to update the reference.
Update - Solved using Powershell
Please see this related question and answer on adding and removing references using Powershell
csproj
files are XML files - you can easily write a command line application to manipulate these files (adding, removing nodes etc).
You can call such a command line application from your batch file.
You can find the schema for this file at:
%windir%\Microsoft.NET\Framework\[framework version]\Microsoft.Build.xsd
As described in this SO answer.
这篇关于可以通过批处理文件以编程方式删除并添加对csproj的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!