पर सशर्त संकलन प्रतीकों (DefineConstants) को कैसे पास करते हैं, तो this और this दोनों स्पष्ट हैं। बस /p:DefineConstants="SYMBOL"
आप एमएसबिल्ड
यह एक परीक्षण परियोजना में भी मेरे लिए बिल्कुल भी काम नहीं करता है। मुझे उम्मीद है कि गुजरने/पी: DefineConstants = "SYMBOL" csproj में परिभाषित किसी भी सशर्त संकलन स्थिरांक को ओवरराइड करेगा। ऐसा नहीं है लेकिन ...
पूर्ण कोड नीचे लिस्टिंग:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DefineConstants
{
class Program
{
static void Main(string[] args)
{
#if DEV
Console.WriteLine("DEV");
#elif UAT
Console.WriteLine("UAT");
#else
Console.WriteLine("No environment provided");
#endif
}
}
}
.csproj फ़ाइल है: का उपयोग कर
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{57A2E870-0547-475C-B0EB-66CF9A2FE417}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DefineConstants</RootNamespace>
<AssemblyName>DefineConstants</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
बनाया:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild DefineConstants.sln /p:DefineConstants="DEV;DEBUG" /p:Configuration="Debug" /p:Platform="x86"
कार्यक्रम चल रहा है पता चलता है:
No environment provided
सहायता!
समाधान पर राइट क्लिक करें -> स्वच्छ समाधान -> अपने निर्माण आदेश को पुनः प्रयास करें। मदद हो सकती है। – Alex
क्या आपने एसएसपीआरजे फ़ाइल पर एमएसबिल्ड का उपयोग करने की कोशिश की है? – KazR