MSBuild passing parameters to CallTarget

MSBuild targets aren’t designed to receive parameters. Instead, they use the properties you define for them. <PropertyGroup> <Environment>myValue</Environment> </PropertyGroup> <Target Name=”Deploy”> <!– Use the Environment property –> </Target> However, a common scenario is to invoke a Target several times with different parameters (i.e. Deploy several websites). In that case, I use the MSBuild MSBuild task … Read more

What is the difference between ‘DependsOnTargets’ and ‘AfterTargets’?

DependsOnTargets Defines the targets that must be executed before the target can be executed. <Target Name=”DependsOn” DependsOnTargets=”DependencyTarget1;DependencyTarget2″> <Message Text=”Target : DependsOn”/> </Target> <Target Name=”DependencyTarget2″> <Message Text=”Target : DependencyTarget2″/> </Target> <Target Name=”DependencyTarget1″> <Message Text=”Target : DependencyTarget1″/> </Target> Output > Target : DependencyTarget1 > Target : DependencyTarget2 > Target : DependsOn BeforeTargets and AfterTargets (Only available in … Read more

MSBuild target package not found

I just got this working without installing VS2010 by following these steps on the build server: If .NET Framework 4 isn’t installed, install it Install the Web Deployment tool from http://www.iis.net/download/webdeploy From the C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0 folder on your dev machine copy the “Web” and “Web Applications” folders to the equivalent directory on your build server. … Read more

Different ways to pass variables in MSBuild

$(…)is used to access Property value (More info on Property element) <PropertyGroup> <Configuration>Debug</Configuration> </PropertyGroup> <Message Text=”Configuration = $(Configuration)”/> @(…) is used to access Item value (More info on Item element) <ItemGroup> <Reference Include=”System.Data”/> <Reference Include=”System.Web.*”/> </ItemGroup> <Message Text=”References = @(Reference)”/> %(…) is used to acces Item Metadata value (More info on Item Metadata). It’s also … Read more

How get exec task output with msbuild

Good news everyone! You can now capture output from <Exec> as of .NET 4.5. Like this: <Exec … ConsoleToMSBuild=”true”> <Output TaskParameter=”ConsoleOutput” PropertyName=”OutputOfExec” /> </Exec> Simply: Add ConsoleToMsBuild=”true” to your <Exec> tag Capture the output using the ConsoleOutput parameter in an <Output> tag Finally! Documentation here

Visual Studio 2017 and the new .csproj InternalsVisibleTo

Just in case anyone would like to put InternalsVisibleTo within a .csproj file instead of AssemblyInfo.cs (a possible scenario is to have a naming convention between a project under test and a test project), you can do it like this: <ItemGroup> <AssemblyAttribute Include=”System.Runtime.CompilerServices.InternalsVisibleTo”> <_Parameter1>$(MSBuildProjectName).Test</_Parameter1> </AssemblyAttribute> </ItemGroup> Having this the following code will be generated [assembly: … Read more

Getting msbuild.exe without installing Visual Studio

The latest (as of Jan 2019) stand-alone MSBuild installers can be found here: https://www.visualstudio.com/downloads/ Scroll down to “Tools for Visual Studio 2019” and choose “Build Tools for Visual Studio 2019” (despite the name, it’s for users who don’t want the full IDE) See this question for additional information.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)