我正在编写一个简短的批处理文件来准备一个带有示例项目的控件库 DLL,以便通过 sip 文件进行部署,并且有以下问题.
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.
给定一个位于已知位置的 csproj 文件和一个位于已知位置的 DLL,是否可以从批处理文件(通过第三方命令行 exe 或其他脚本)以编程方式更新 csproj 以添加新的 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
假设批处理文件在/Build级别,有没有办法修改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 plus 示例,因此需要更新参考.
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.NETFramework[framework version]Microsoft.Build.xsd
如this SO answer中所述.
这篇关于可以通过批处理文件以编程方式删除和添加对 csproj 的引用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!