$(ProjectName)和$(TargetName)MSBuild宏不起作用 [英] $(ProjectName) and $(TargetName) MSBuild macros not working

查看:92
本文介绍了$(ProjectName)和$(TargetName)MSBuild宏不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Stduio 2015 Community Edition.我已经加载了一个C#项目,并希望将其配置为使用影子构建,以便源文件不会与任何二进制文件或中间构建文件混为一谈.试图使用VS UI设置C#项目的[输出]/[中间输出]目录路径-唯一可编辑UI的输出路径是"bin"路径,并且它不接受

I am using Visual Stduio 2015 Community Edition. I have loaded a C# project and want to configure it to use shadow building, so that source files are not messed up with any binaries or intermediate build files. Tried to set the [output]/[intermediate output] directory paths of the C# project using the VS UI - the only UI-editable output path is the "bin" one and it doesn't accept MSBuild macros. Then I've unloaded the project and manually edited it. Also set the IntermediateOutputPath which is not available in the VS UI when using C# project, but when using C++ one all such kind of directories are editable. Currently, the OutputPath is set to: <OutputPath>$(SolutionDir)..\build_$(SolutionName)_$(Configuration)_$(Platform)\$(ProjectName)</OutputPath>

$(ProjectName)由于某种原因为空.尝试过$(TargetName)(使用它不正确,仅用于测试),但它也是空的.有什么建议吗?

$(ProjectName) is empty for some reason. Tried $(TargetName) (it is not correct to use it but just for the test) but it is empty, too. Any suggestions?

推荐答案

问题是某些MSBuild属性(如ProjectName)是在.csproj文件中的以下行之后设置的.

The problem is that some of the MSBuild properties like ProjectName are set after the following line in your .csproj file.

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

在此行之后,您可以访问所有变量.

After this line you can access all variables.

这篇关于$(ProjectName)和$(TargetName)MSBuild宏不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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