msbuild-task

When implementing a microsoft.build.utilities.task how to i get access to the various environmental variables of the build?

自闭症网瘾萝莉.ら 提交于 2019-12-06 03:18:07
When implementing a microsoft.build.utilities.task how to i get access to the various environmental variables of the build? For example "TargetPath" I know i can pass it in as part of the task XML <MyTask TargetPath="$(TargetPath)" /> But i don't want to force the consumer of the task to have to do that if I can access the variable in code. http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx I worked out how to do this public static class BuildEngineExtensions { const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags

How can I execute programs in my %PATH% with MSBuild?

馋奶兔 提交于 2019-12-06 02:16:34
Note: I'm using Mercurial as an example here, because that's what I'm trying to get to work with MSBuild right now. But the problem is not limited to Mercurial, it happens with every external program that is somewhere in my %PATH% variable (I tried the same with PowerShell, for example). So I didn't put the Mercurial tag on this question on purpose, because this is not about Mercurial! What I actually want to do: I want my build script to get the current revision number from my Mercurial repository and store it in a file. The simplest way to do this from the command line is: hg id -i >rev.txt

Using MSBuild, how to construct a dynamic string from iterating over files in an ItemGroup?

喜你入骨 提交于 2019-12-06 00:59:11
问题 I need to create multiple /testcontainer: parameters to feed into a task that exec's MsTest. I have the following : <ItemGroup> <TestFiles Include="$(ProjectPath)\**\UnitTest.*.dll" /> </ItemGroup> for each match in TestFiles I would like to build a string like so: "/testcontainer:UnitTest.SomeLibrary1.dll" "/testcontainer:UnitTest.SomeLibrary2.dll" "/testcontainer:UnitTest.SomeLibrary3.dll" I am trying to use the internals of MSBuild without having to create a custom task, is this possible ?

How do you recursively call tasks in MSBuild?

青春壹個敷衍的年華 提交于 2019-12-05 18:30:45
E.g. I want to call these scripts passing diff params each time: <ItemGroup> <SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Tables\*.sql" /> <SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Functions\*.sql" /> <SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Views\*.sql" /> <SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\ForeignKeys\*.sql" /> <SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\StoredProcedures\*.sql" />

How can I use MSBuild 'afterbuild' tasks to edit a .config file?

≯℡__Kan透↙ 提交于 2019-12-05 18:28:09
I have a .config in a target project and I need to add a line to it programmatically via an MSBuild task. Pseduo operations like: find target .config file determine the value of attributes for new node (e.g. 'id' and 'version' for 'package' node) insert new node in correct parent node save changes The .config file at $TargetProjectDir\Config\packages.config: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="ABC" version="1.1.0.4" /> <package id="XYZ" version="2.0.0.0" /> </packages> Needs to look like this afterwards: <?xml version="1.0" encoding="utf-8"?> <packages> <package id=

Use XSD Build task in c# project

烈酒焚心 提交于 2019-12-05 16:56:48
How can I use the c++ XSD Task in a c# project? I have already created the task in the csproj file like this: <Target Name="BeforeBuild"> <XSD Namespace="$(RootNamespace).Xml" Language="CS" GenerateFromSchema="classes" Sources="Xml/schema.xsd" /> </Target> but the build output says, although intellisense offers me the XSD task while editing the project file: Error 1 The "XSD" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface.

Visual Studio 2017 MSBuild Task Development

烈酒焚心 提交于 2019-12-05 15:23:14
With developing an custom MSBuild Task with Visual Studio 2017 RC, I have the following problem: As soon as I add other dependencies than just Microsoft.Build.Utilities.Core (using v15.1.0-preview-000458-02 for .NET Core Support), I cannot load the task into another .csproj MSBuild project as the dependencies are not found. Is there a way to automatically copy all dependencies to the Debug folder? Or do I have to publish it every time I want to test it? Update1: The problem with publish was something local to my environment and has been fixed. Update2 : It seems that as soon as I change the

MSBuild Build Sequence

佐手、 提交于 2019-12-05 08:25:41
Looking at this article from MS, I have a question about the SolutionToBuild section. <ItemGroup> <SolutionToBuild Include="$(SolutionRoot)\path\MySolution.sln /> <SolutionToBuild Include="$(SolutionRoot)\Scribble\scribble.sln" /> <SolutionToBuild Include="$(SolutionRoot)\HelloWorld\HelloWorld.sln" /> <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" /> </ItemGroup> It says that the sequence of the build is determined by the order above. So, for example, MySolution would be built before scribble. However, is this safe if scribble is dependant on MySolution? For example,

Visual Studio integrated custom MSBuild task behaviour

倖福魔咒の 提交于 2019-12-05 06:19:00
问题 I was looking around the net for a NUnit custom MSBuild task that would run on every build and also nicely play with Visual Studio UI (2008 is my version). I found MSBuild.Community.Tasks project that was great, but failed in Visual Studio integration part. What I actually wanted to have is get failed tests displayed as warnings/errors in VS's error list window (and also FAILED project build when tests are not successful). So I wrote my own custom MSBuild task that does the job exactly how I

Pass custom msbuild target from Solution to Project

為{幸葍}努か 提交于 2019-12-05 04:16:25
I have a Solution with a large number of associated .csproj files. Each .csproj file has a <Target Name="PublishQA">... . The build fails when I try to compile the whole solution: > msbuild mysolution.sln /t:PublishQA` "c:\myproj.sln" (publishqa target) (1) -> c:\myproj.sln.metaproj : error MSB4057: The target "PublishQA" does not exist in the project. [c:\myproj.sln] When I build the .csproj project directly, it builds just fine. How do I tell msbuild to pass the target to the project files??? As a case you can create seperate targets file which explicitly builds your solution, <!-- mytargets