vb.net - 项目级条件编译常量

标签 vb.net conditional-compilation

在尝试构建我的 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>

最佳答案

我更改了此块中的 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>

它就像一个魅力!

关于vb.net - 项目级条件编译常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1297306/

相关文章:

c# - 为可观察集合实现中介设计模式

c++ - 仅包含操作系统上的某些库

c - 预处理器参数和在 C 中编译#ifndef#ifdef

rust - Rust 条件编译属性覆盖了多少行?

vb.net - 在文本文件的 ReadLine 之间等待 X 秒

javascript - DotNetBrowser 调用 JS 函数并从 C# 返回值

c# - 是否有与 Alternate ItemTemplate 类似的方法来执行此操作

c# - 使用 ORM 创建数据库

javascript - Browserify、minifyify、条件编译

c++ - 条件代码依赖于模板参数比较