添加自定义信息的csproj文件 [英] Adding custom information to CSPROJ files

查看:434
本文介绍了添加自定义信息的csproj文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我们的开发生命周期的一部分,我们有一些过程,我们对在我们的项目C#源运行。

As part of our development life cycle we have a number of process that we run against the C# source in our projects.

的过程赶走一个GUI,当前读取* .csproj的文件以查找项目中使用的源文件。这工作得很好。

The processes are driven off a GUI that currently reads the *.csproj file to find the source files used within the project. This works fine.

我们现在有一个新的要求,以提供需要的呼叫到一个Web服务的一些验证过程。该网络服务需要提供一些凭证是特定项目。理想情况下,我们可以输入并存储* .csproj的文件中,这些凭据,但我看不出它延伸的手段 - 有

We now have a new requirement to provide some validation processes that require a call out to a web-service. The web-service needs to be provided with some credentials that are project specific. Ideally we could enter and store these credentials within the *.csproj file but I don't see a means of extending it - is there?

我们真的不想?引进新的配置。文件只是这些设置,如果我们能帮助它。是否有可能来存储信息,如这是* .csproj的文件,如果不是有没有任何其他地方把它。

We don't really want to introduce a new config. file just for these settings if we can help it. Is it possible to store information like this is the *.csproj file, if not is there any other place to put it.

感谢

推荐答案

.csproj的文件基本上是一个的 MSBuild的文件,因为这样你可以用自定义值扩展。如果您在Visual Studio中的一个项目右键单击并选择卸载项目,该项目将灰色去,你就可以再次右键单击并选择编辑[ProjectFileName]的.csproj 。然后,您可以添加类似于下面的内容:

The .csproj file is basically an MSBuild file, as such you can extend it with custom values. If you right-click on a project in Visual Studio and choose "Unload Project", the project will "grey out" and you can then right-click again and choose Edit [ProjectFileName].csproj. You can then add something similar to the following:

<PropertyGroup Label="Custom">
  <Badger>1</Badger>
</PropertyGroup>

这的的当项目被修改被持久化(即文件添加/删除),你可以从文件中检索值,使用您选择的方法。

This should be persisted when the project is modified (i.e. files added/removed) and you can retrieve the values from the file, using the method of your choice.

这篇关于添加自定义信息的csproj文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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