可以删除和添加的引用通过一个批处理文件编程的csproj? [英] Possible to remove and add a reference to csproj programmatically via a batch file?

查看:246
本文介绍了可以删除和添加的引用通过一个批处理文件编程的csproj?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写这封信通过SIP文件很短的批处理文件,以prepare控件库DLL与示例项目的部署,并有以下问题。

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.

由于在已知的位置,并在已知位置的一个DLL文件的csproj,是否有可能以编程方式更新从批处理文件的csproj(通过第三方命令行EXE,或其他脚本)来添加新的DLL?

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?

我的文件夹结构

/Build 
   /SDK
      /WPF
          /4.0 : ControlLibrary.dll sits here
   /Examples
      /WPF
          /4.0 : Examples.csproj sits here

假设批处理文件是在/构建级别,有没有什么办法来修改Examples.csproj参考ControlLibrary.dll?

Assuming the batch file is at the /Build level, is there any way to modify Examples.csproj to reference ControlLibrary.dll ?

我想弄清楚,为什么我的结构是怎样的,这是我想部署一个例子的csproj我的控件库出货的原因。 Examples.csproj应参考下SDK /模糊化的控件库。 Examples.csproj上也存在开发主干(它已被复制),并在开发解决方案成为非模糊形式ControlLibrary.csproj的输出引用。

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.

基本上什么即时创建这里是一个文件夹结构,压缩和运送ControlLibrary加的例子,因此,需要更新的参考。

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.

更新 - 使用PowerShell的解决

请参阅此相关的问题和解答有关 中使用PowerShell添加和移除引用

Please see this related question and answer on adding and removing references using Powershell

推荐答案

的csproj 文件是XML文件 - 你可以写一个简单的命令行应用程序来处理这些文件(添加,删除节点等等)。

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

这个SO回答。

这篇关于可以删除和添加的引用通过一个批处理文件编程的csproj?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆