OutDir vs OutputPath for Visual studio 2015 and Asp.Net Core

TL;DR

In MSBuild for Asp.Net Core use /p:OutputPath parameter, not /p:OutDir nor both.

Full story

We’ve used psake powershell build for ASP.Net 4.61 project and passed both parameters
msbuild  /p:OutDir=“$binariesDir\” /p:OutputPath=“$outPath\”
Actually /p:OutputPath was ignored(almost, see below) and build was saved to specified in /p:OutDir folder.
When I included Asp.Net Core project into solution, it’s failed because dll, referenced by the Core project, was saved to OutDir folder, but Asp.Net Core project tried to find it in OutputPath folder.
I’ve tried to remove /p:OutputPath  parameter (as suggested in OutputPath vs OutDir thread: “to keep the OutputPath that is generated by Visual Studio, then set the OutDir as a command argument”), Asp.Net Core project failed because dll was saved to OutDir folder, but Asp.Net Core project tried to find it in relative bin\Release\ folder.
When I removed OutDir parameter and specified /p:OutputPath=“$binariesDir\” build was successful,  but package for MSDeploy, specified in a custom MS Build step, was created in a relative path obj\Release\Package rather than specified $binariesDir folder, so I needed to adjust package path.
Current VS 2015 MSDN page  Common MSBuild Project Properties doesn’t document OutDir , but only OutputPath.
 
Note that previously MSDN recommended the opposite: “OutputPath has been deprecated and OutDir should be used instead whenever possible. ”
   

Is it possible to determine Visual Studio edition during c# compile time

To use MS Fakes shims, I had to conditionally exclude related tests  to allow easily bypass them on Community and Professional Editions of the Visual Studio.
#if !FAKES_NOT_SUPPORTED
[ TestMethod()]
Fakes related code
#endif
I tried to find does edition automatically pre-defined by compiler, but it’s not included in Conditional Compilation Constants

Furthermore,  these constants seems defined in VB only, and not in c# and not updated since VS2008.

The reasons are discussed in “Pre-defined Constants, preprocessor directives, etc… “

The “C# Language Designers” decided to not include constants in the fashion in which C/C++ allows them.  To allow some, or even one, would open a Pandora’s Box of voices suggesting new constants to be added.

But I disagree,  because if the limitation coming from VS , it should provide a way to  determine it in pre-condition.
The related article shows how to check installed Visual Studio on run-time
Unfortunately I didn’t find, is it possible to determine Visual Studio edition  during c# compile time?

#compile-time, #constants, #visual-studio

Visual Studio 15 build Task could not find “sgen.exe”

On new Windows 10 machine with Visual Studio 2015 installed when I tried to build my solution from batch file, I’ve got an error

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(2769,5): error MSB3086: Task could not find “s
gen.exe” using the SdkToolsPath “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\” or the regis
try key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86”. Make sure the Sdk
ToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Mic
rosoft Windows SDK is installed

http://stackoverflow.com/questions/2731365/running-msbuild-fails-to-read-sdktoolspath
suggested to Install Microsoft Windows SDK for Windows 7 and .NET Framework AKA v7.1.

But I’ve got error: Windows SDK Setup
Some Windows SDK components require the RTM .NET Framework 4. Setup detected a pre-release version of the .NET Framework 4. If you continue with Setup, these components will not be installed. If you want to install these components, click Cancel, then install the .NET Framework 4 from http://go.microsoft.com/fwlink/?LinkID=187668 and then rerun Setup.
The message is misleading, because I have .net framework 4.6, but I Tried to install the .NET Framework 4 from https://www.microsoft.com/en-us/download/details.aspx?id=17851
I’ve got expected message:
Same or higher version of .NET Framework 4 has already been installed on this computer

I’ve tried different suggestions trying to change path and properties in Microsoft.Common.targets, but finally gave up and

Copy sgen.exe, al.exe and al.exe.config from C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\
to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\

as suggested at http://stackoverflow.com/questions/4923131/task-could-not-find-al-exe-using-the-sdktoolspath

#build, #visual-studio

bad revision ‘rm’ error, when using git filter-branch –index-filter if called from batch file

I was trying to move a few directories from one repository to another and answer http://stackoverflow.com/a/17867910/52277 suggests to use

    git filter-branch –index-filter ‘git rm –cached -qr –ignore-unmatch — . && git reset -q $GIT_COMMIT — apps/AAA libs/XXX’ –prune-empty — –all
I’ve put the command into batch file and got the error
> fatal: bad revision ‘rm’
The same error happened for an example from git documentation https://git-scm.com/docs/git-filter-branch
    git filter-branch –index-filter ‘git rm –cached –ignore-unmatch — buildMaster.bat’ HEAD
However when I was running the command in git bash, it didn’t  show any error and worked successfully.

It was acceptable for me. But I am still curious why including inside .bat cause an error with unclear message

#batch, #branches, #error, #git

Insert new line in multiple xml files using Visual Studio

I needed to insert new line after existing one in multiple similar xml files.
In Visual Studio open “replace in files” dialog and tick “use regular expression”
In “find” escape “/” as “\/”
     <param name=”ExistingKey” value=”(.*)” \/>
In “Replace” repeat original string, then add n and add a new string
     <param name=”ExistingKey” value=”$1″ />\n  <param name=”NewKey” value=”new value” />
Related links:

Stash, Pull, Stash Apply as one git command

I noticed that I often do the same sequence of git commands.
run 
notepad ~/.gitconfig
and add
[alias]
spa = !git stash && git pull && git stash apply
Then execute
git spa

Original Post:

With a help of an answer http://stackoverflow.com/a/5401381/52277
I’ve created .bashrc with command
notepad ~/.bashrc
and added the following
 
StashPullApply() {

git stash

git pull

git stash apply

}
Now I can use just the name in git bash
StashPullApply
 Comment from  Daniel Laughland pointed me to alternative methods to do it with pull rebase http://stackoverflow.com/questions/30208928/can-git-pull-automatically-stash-and-pop-pending-changes

POSTSHARP error PS0052: The plug-in “PostSharp.Patterns.Diagnostics.Weaver” was not found

After some merge of source code branches I’ve got a build error
 POSTSHARP : error PS0052: The plug-in “PostSharp.Patterns.Diagnostics.Weaver” required by the type “PostSharp.Patterns.Diagnostics.ILogAspect” was not found. 
[C:Builds\MAIN_MasterSourcesmainServiceInterfacesmyProj.csproj]
I wasn’t able to find immediately which code caused the error, and google also didn’t give me an answer.
After some investigation I found that PSproj file had missing entries for PostSharp.Toolkit.Diagnostics.Weaver.dll and PostSharp.Toolkit.Diagnostics.Weaver.NLog.dll.

It will be easier if error PS0052 will include name and line from PSproj file

<Project xmlns=http://schemas.postsharp.org/1.0/configuration xmlns:dg=clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics ReferenceDirectory={$ReferenceDirectory} >
  <Property Name=LoggingBackEnd Value= nlog  />
  <Using File=default />
  <!– if the following 2  entries will be missing, it would cause PS0052 error –>
<Using File=”……packagesPostSharp.Toolkit.Diagnostics.NLog.2.1.1.12toolsPostSharp.Toolkit.Diagnostics.Weaver.NLog.dll” />
  <Using File=”……..packagesPostSharp.Toolkit.Diagnostics.2.1.1.12toolsPostSharp.Toolkit.Diagnostics.Weaver.dll” /> 
  
  <dg:LoggingProfiles>
    < dg:LoggingProfile Name = Exceptions OnExceptionOptions=IncludeParameterType | IncludeParameterName | IncludeParameterValue | IncludeThisArgument OnEntryLevel=None OnSuccessLevel = None />
  </dg:LoggingProfiles>

  <Multicast>
    <!– Add exception logging to everything  .–>
    < LogExceptionAttribute xmlns=clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics  AttributeTargetAssemblies=“MyProj.ServiceInterfaces AttributeTargetTypes=MyProj.ServiceInterfaces.* AttributeTargetMembers= * />
  </Multicast>
</Project>