我试图在.Net v4.0上同时进行发布和调试,其中我有一个MSBuild项目文件,而不是一个解决方案文件。我希望使用相同的构建项目文件,但只需覆盖在"Debug“和"Release”之间切换的配置属性。
当我按以下方式执行时
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe
buildinv.proj /target:rebuild "/property:Configuration=Debug“/verbosity:Diagnostic
我得到以下错误
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9):错误:未为项目‘buildinv.proj设置OutputPath属性。请检查以确保您已为此项目指定了有效的配置和平台组合。Configuration='Debug‘Platform='’。
我可以看到错误发生在_CheckForInvalidConfigurationAndPlatform中。
但是,如果我传递一个OutputPath属性,它将工作。
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe
buildinv.proj /target:rebuild "/property:Configuration=Debug“"/property:OutputPath=.”
这是已知的窃听器吗?在需要重写配置属性的地方,我将被迫重写OutputPath属性,即使我不希望这样做。
提前谢谢。
发布于 2012-01-09 13:13:46
在我的项目文件中,OutputPath属性是在为每个配置和平台指定的属性组中定义的。如果您没有设置正确的平台,则不会设置OutputPath属性,您的构建将失败。
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>将Platform属性添加到命令行中:
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;Platform=AnyCPU" /verbosity:Diagnostic发布于 2014-08-27 23:12:57
向项目文件中添加以下内容之一。这个错误意味着OutputPath环境变量没有得到它的值。通过从"Condition="中删除PropertyGroup,默认情况下,将始终为任何平台或配置设置OutputPath。
<PropertyGroup>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(DefaultOutputDirectory)</OutputPath>
</PropertyGroup>发布于 2015-01-26 14:26:49
如果不想修改项目文件,也可以在命令中为构建指定OutputPath:
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;OutputPath=C:\MyOutputPath" /verbosity:Diagnostichttps://stackoverflow.com/questions/8782271
复制相似问题