We have a custom TraceListener (inherited from System.Diagnostics.TraceListener) which we use for our ASP.NET web application logging. It's been working great - no issues. Then all the sudden it stopped working in our dev environment (TraceListener.TraceEvent() stopped firing). We are baffled as to why it stopped working. The only changes we really made in code was added more build configurations (Dev, Test, Stage, Prod). Before, it only had Debug and Release.
I notice that when I test locally having built using the Debug configuration, TraceListener.TraceEvent() is fired just fine. When I switch to another build configuration (i.e. Test), then TraceEvent() is never fired anymore. Here's a snippet of my web .csproj file:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;SkipPostSharp</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;SkipPostSharp</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Stage|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Prod|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
I'm not sure why switching build configurations seems to turn off our logging. Can anyone point me in the right direction?
Figured out the issue. My code which called System.Diagnostics.TraceSource.TraceEvent() to broadcast trace events was in another Project. I needed to enable tracing on THAT project via:
<DefineConstants>TRACE</DefineConstants>
I mistakenly assumed that all I needed to focus on was the main target project (i.e. the Web project). It makes sense now - the project/assembly which calls the System.Diagnostics.TraceSource.TraceEvent() must have tracing enabled (via the project properties for the targeted build configuration) to broadcast those traces. Then your trace listeners can hear them. :)
Related
I cloned a repo and in it I got a .psproj file. I tried opening in Visual Studio 2017 (since notepad++ showed it contained xml much like VS Solutions). In VS also it opened showing internal xml and not as a proj/solution file. Same outcome with VS Code.
So my question is
What is a psproj file?
Since it was contained in a PowerShell folder, so is my assumption correct that it is a powershell project file?
What is the IDE to view these projects?
The file's contents:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>6CAFC0C6-A428-4d30-A9F9-700E829FEA51</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MyApplication</RootNamespace>
<AssemblyName>MyApplication</AssemblyName>
<Name>Bootstrapper</Name>
</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>
<ItemGroup />
<ItemGroup>
<Compile Include="Script.ps1" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="Build" />
</Project>
It's a powershell project file, but not for Visual Studio, it's for Powershell Studio. The powershell projects for visual studio are .pssproj. It took me forever to figure this out because everyone here was too busy arguing about whether this was a valid question to pro
Ok so going by the comments on questions, it is a powershell project file.
To enable your VS to understand such files, one needs to install respective extension to your VS2015 or VS2017 or VS2013
Nice article on this is here
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 am using MVC3 application,and am creating packages through TFS build.it was working fine when i am creating Packages through MSBuild.
Previously Website1 has my application(Website1/Application) in IIS,now i want to relocate my Application under Website2,like(Website2/Application),in the Package/PublishWeb properties.
But my TFS(MSBuild) Build was failed with following error
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets
(3847): Web deployment task failed. (Site 'Website2' does not exist.).
do i need to change may Sitename any other place? Please help us to fixing this issue.
My configuration
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DeployOnBuild>true</DeployOnBuild>
<DeployTarget>MsDeployPublish</DeployTarget>
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
<CreatePackageOnPublish>true</CreatePackageOnPublish>
<MsDeployServiceURL>localhost</MsDeployServiceURL>
<DeployIisAppPath>Analytics/Application</DeployIisAppPath>
</PropertyGroup>
In project file, normally we can see the following for setting the project output path. Now I am wondering if there is a way to set additional output path. i.e., the built binaries will be copied to the additional path as well.
<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>
It would be trivial to add a post-build event to your project/solution configuration, which copies the files from the original build location to your specified new one. Go to your project properties, and under "Build Events" add the following to your post-build event command line:
xcopy /E $(ProjectDir)bin\Release\ [pathToMyDestination]
As an aside, I'm guessing you want to publish your release build to a host. In that case it's worth looking into continuous integration software, which gives you powerful capabilities. We've used several and are currently using Team City (free).