项目级条件编译常量

发布于 2024-08-01 19:18:39 字数 4517 浏览 5 评论 0原文

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

I am getting a project-level conditional compilation constant error while trying to build my VB.NET project. It reads:

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.

I recently upgraded it to the latest version (from 2.0), and I have a feeling that this has something to do with it.

What does this mean? I am clueless...

Here is my project file:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

剪不断理还乱 2024-08-08 19:18:39

在 .vbproj 文件中,您必须使用逗号分隔定义常量,这与 .csproj 文件中使用的分号不同。 因此,如果您想要 DEBUG 和 TRACE 标志,您需要:

<DefineConstants>DEBUG,TRACE</DefineConstants>

In .vbproj files you must delimit define constants with commas, unlike the semicolons used in .csproj files. So if you want DEBUG and TRACE flags you want:

<DefineConstants>DEBUG,TRACE</DefineConstants>
放手` 2024-08-08 19:18:39

我有同样的问题。 但是当我使用“,”作为常量之间的分隔符而不是“;”之后,它起作用了。

因此,请尝试仅使用“,”(逗号)。

I had the same problem. But after I used "," as the separating character between constants instead of ";", it worked.

So have a try with "," (comma) only.

痞味浪人 2024-08-08 19:18:39

我将这个块中的 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>

的效果非常好!

I changed the DefineConstants tag in this block:

 <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>

to

<DefineConstants>DEBUG</DefineConstants>

It worked like a charm!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文