我在尝试构建我的vb.net项目时遇到项目级条件编译常量错误。它写着:
project-level conditional compilation constant 'VB_VER=9.0,TARGET="exe",CONFIG="Debug",_MyType="Console",PLATFORM="AnyCPU",DEBUG;^^ ^^ TRACE' not valid: Character is not valid.
我最近将它升级到最新版本(从2.0开始),我觉得这与它有关。
这意味着什么?我很无能......
这是我的项目文件(按要求):
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>local</ProjectType>
<ProjectVersion>7.10.3077</ProjectVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5810CBEF-671E-4845-BBE3-BC3470C3EE18}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<AssemblyName>svchost</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Exe</OutputType>
<FileUpgradeFlags>
</FileUpgradeFlags>
<MyType>Console</MyType>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<StartupObject>Sub Main</StartupObject>
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>svchost.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<NoStdLib>false</NoStdLib>
<Optimize>false</Optimize>
<WarningLevel>4</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>svchost.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>false</DebugSymbols>
<NoStdLib>false</NoStdLib>
<Optimize>true</Optimize>
<WarningLevel>4</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
答案 0 :(得分:3)
我更改了此块中的DefineConstants标记:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>svchost.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<NoStdLib>false</NoStdLib>
<Optimize>false</Optimize>
<WarningLevel>4</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>full</DebugType>
</PropertyGroup>
到
<DefineConstants>DEBUG</DefineConstants>
它就像一个魅力!
答案 1 :(得分:3)
我有同样的问题。但是在我使用“,”作为常量之间的分隔符而不是“;”之后,它起作用了。所以只试试“,”。
答案 2 :(得分:1)
与.csproj文件中使用的分号不同,在.vbproj文件中必须使用逗号来分隔定义常量。因此,如果要使用DEBUG和TRACE标志,则需要:
<DefineConstants>DEBUG,TRACE</DefineConstants>