VS 破坏解决方案文件
我有一个(python)脚本,可以完成以下任务:
- 扫描文件夹以查找
.csproj
和.vcproj
文件。 - 根据
.csproj
和.vcproj
文件编写文本,创建一个包含所有项目的解决方案文件。 - 构建该解决方案。通过从命令行调用
devenv.exe /Build
(Python 上的subprocess.call
)。
我的问题是:当我构建时,VS 更改了我的 SLN 中的配置。具体来说,在 SLN 的 Win32
配置上,所有 .csproj
项目(.NET 项目)从 x86
切换到 x64
并从构建中标记出来。
尝试没有成功: 更改 SLN,使所有 .NET 位于 x86
上,而 VC 位于 x86
解决方案配置下的 Win32
上。再次,VS 在打开 SLN 时破坏了它:VC 会自动更改为目标 x64 并标记为在构建之外。
尝试有效但相当笨拙: 首先,我让 VS 破坏文件。我设法做到这一点的唯一笨拙的方法是从命令行调用 /Build
然后调用 /Clean
。接下来,我通过替换 VS 损坏的配置来修复 SLN 文件。现在,当我 /Build
它时,VS 不会更改 SLN。
那么:
- 有人有更优雅的解决方案吗?
- 除了
/Build
-/Clean
之外,还有什么更好的方法可以让 VS 破坏文件?
I have a (python) script that accomplishes the following:
- Scanning a folder looking for
.csproj
and.vcproj
files. - Creating a solution file to contain all the projects by writing text according to the
.csproj
and.vcproj
files. - Building that solution. By calling
devenv.exe /Build
from command line (subprocess.call
on python).
My problem is: When I build, VS changes configuration in my SLN. Specifically, on SLN's Win32
configuration, all the .csproj
projects (.NET projects) switch from x86
to x64
and are marked out from the build.
Attempt that did not work:
Changing the SLN to have all the .NETs at x86
and the VCs on Win32
under x86
solution config. Again, VS breaks it when it opens the SLN : VCs are automatically change to target x64
and marked out of the build.
Attempt that worked but quite clumsy:
First, I let VS break the file. The only clumsy way that I managed to do that is calling /Build
then /Clean
from command line. Next, I fix the SLN file by replacing the configs that VS broke. And now when I /Build
it, VS does not alter the SLN.
So:
- Anyone with a more elegant solution ?
- Any nicer way to make VS break the file other then
/Build
-/Clean
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的答案是,缩进对于 VS
sln
解析器很重要。所以公司的人声称这一切在当天都有效,我发现很难相信。我一遍又一遍地扫描构建它的代码和生成的 sln 文件,但看不出任何区别。
因为我没有看空格!
一个月前,我无意中更改了构建 .sln 文件的代码,以使用不同的缩进写入该文件。
这是文件的区别:
这有效,因为该文件与 VS 制作的文件相同,包括缩进:
这个文件导致 VS 重新编辑,并且作为副作用破坏了我们所需的解决方案配置:
The simple answer is, indentation matters to the VS
sln
parser.So folks at the company claimed it all worked back in the day, and I found it hard to believe. Over and over again I scanned the code that builds it and the sln file that is produced and couldn't tell any difference.
Beacuse I didn't look at whitespaces !
Month ago I innocently changed the code that builds the .sln file to write the file with different indentation.
Here's the difference of the files:
That worked, because the file was identical to a VS-made file, including the indenetation:
This one caused VS to re-edit, and as a side eefect to break our desired solution configuration: