I'm working in VS 2013 with a C# Xamarin iOS project. I would like to add a Conditional compilation symbol without effecting anyone else or having to go into Configuration Manager and say copying Debug (primarily so that if someone modifies Debug I don't miss the change).
I've read a few posts stating to try adding something like this to the csproj.user file ...
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>$(DefineConstants);__MY_NEW_SYMBOL__</DefineConstants>
</PropertyGroup>
... but this just removes all the other symbols for the project.
Is there a way I can modify the csproj.user file to achieve this?
I see this is a really old question. I'm not sure if anyone is actually using VS 2013 anymore, but it works in VS2017, exactly the way it's done in the question.
But! I had to run Build -> Clean Solution first before it worked. 'Rebuild Solution' didn't even do it. I had to Clean first, then build and run it.
I tested it with this code:
#if DEBUG
Console.WriteLine("DEBUG");;
#endif
#if TRACE
Console.WriteLine("TRACE");
#endif
#if __MY_NEW_SYMBOL__
Console.WriteLine("__MY_NEW_SYMBOL__");
#endif
Even though my .user file only defines __MY_NEW_SYMBOL__, I saw all three in the console after running it.
My .csproj file has this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
And my .csproj.user file has this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>$(DefineConstants);__MY_NEW_SYMBOL__</DefineConstants>
</PropertyGroup>
Related
Long story made short, how can I change the icon for a console app in VS Code (.Net 5)? Does it have to be done in the .csproj file? Or is there a command or wizard to do this?
You could use:
<PropertyGroup>
<ApplicationIcon Condition=" '$(Platform)' == 'x86' ">x86.ico</ApplicationIcon>
<ApplicationIcon Condition=" '$(Platform)' == 'x64' ">x64.ico</ApplicationIcon>
</PropertyGroup>
Edit: Although, when you compile your application, you have the option to choose an icon for it.
This is my first time when i came across something like this. For the longest time whenever I want to precisely know the type of the project I use the guidance provided in the link below:
How do you tell the Visual Studio project type from an existing Visual Studio project
And it has been working great for me so far. However, I came across a project where there is no mention of the ProjectType. Below is the XML of .csProj file for the reference.
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{87F6C2DE-6074-4E6D-9854-51EC812F7548}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PL.HR.Services.Employee.DAL</RootNamespace>
<AssemblyName>PL.HR.Services.Employee.DAL</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
I am not sure how can this happen
Is it possible without anyone manually removing the type information from .csproj file?
If not, then under what circumstances does it happen in VS?
Is there anything that we can do to prevent this kind of occurances from happening in the future?
Are you just looking at the xml or are you actually using VS provided services to get this information?
is it really a valid .csproj? or is it just something named .csproj so VS opens it? does VS actually open it without errors?
Some types of projects do not use project type guids as xml elements in a project file, like C++ projects, but then those generally don't end with .csproj. Those types of projects may be implemented in other ways, which implement things in IVsHierarchy and IVsAggregatableProject so you need do to it from code, like one of the pages from your linked answer explains.
I've recently upgraded some solution(s) to Visual studio 2013. All went OK apart from one which now generates the:
Symbol for the modules 'name' were not loaded.
...error every time I run it.
When I look in the modules debug window I can see against the dll (It's a web service dll)
Name Path Optimised User Code Symbol Status
dllName.dll Tempoary ASP.Net...etc. Yes No Skipped Loading...
If I look in the \bin I see the dll and it's coresponding .pdb file.
Checking the build menu for the project I can see Debug Info: full.
Cut a long story short everything looks fine to me except that it's not loading any symbols.
Any idea what I'm missing?
Update
It looks like if I run my solution though IIS express the issue goes away. But running though IIS (8) I still have this problem.
After painfully comparing two project files, one that worked and one that didn't I noticed that the proj that worked had:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
**<Optimize>false</Optimize>**
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Where as my one had
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
**<Optimize>true</Optimize>**
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
By setting the <Optimize> property to false all issues went away.
This answer also seems relevant as the .csproj.user file can be out of sync, I deleted it.
I need to build a C# project as either WinExe or Library depending on the project's configuration.
I've tried both of these methods with no luck:
1) In the general PropertyGroup:
<OutputType Condition=" '$(Configuration)' == 'Release' ">WinExe</OutputType>
<OutputType Condition=" '$(Configuration)' == 'Debug' ">Library</OutputType>
2) In a conditional PropertyGroup:
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputType>WinExe</OutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputType>Library</OutputType>
</PropertyGroup>
Neither of these methods work and the OutputType is always WinExe. The odd thing is that if I change all instances of WinExe to Library, then it's always Library. This is making me think that it is reading them successfully, but either in a strange order or that WinExe takes precedence over Library.
Any ideas?
In the top of your .csproj file you will have two sections that look a bit like this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputType>Library</OutputType>
<!-- Other properties go here -->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputType>Exe</OutputType>
<!-- Other properties go here -->
</PropertyGroup>
Add your OutputType elements to these two conditional PropertyGroup sections and make sure that you remove all other OutputType elements - I've just tested it and it does exactly what you are asking for.
Yes this is very similar to what you have already done, but I know for a fact that the above method works because I've just tried it - my only guess is that something somewhere else in your build is messing things up.
I am writing a fairly simple WPF desktop application and under build\configuration manager, release is not an option. The only available options are Debug, New, and Edit.
Anyone have an idea on why this is?
Related: the control library in the same solution does have release as a build option. It is only missing in the wpf app.
I figured it out.
To fix i copied the propertygroup tag for release build from the xml in the other project to the project that was missing it.
The propertygroup tag thing does fix the problem.
1) Open your project file in notepad.
2) Paste this after the "debug" propertygroup tag:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>