I'm trying to create an archive with msbuild and I can't seem to be able to exclude the resharper folder.
How should the rule excluding all directories that begin with _resharper look ?
Thank you.
Hmm .. it seems that I found it :
<DefaultExclude Include="**\_ReSharper.*\**" />
Related
This sounds really basic but couldn't find any info on internet about it.I am working with msbuild and inside a .proj file I found the following line
<ItemGroup>
<PackageFiles Include="$(TopDir)\**\packages.config" />
</ItemGroup>
I know that ".\" means current directory and "..\" previous one, but what about "**\"?
That 'double star' (i.e. **) in msbuild is used with items.
It means get all sub-directories. In your example code, it can be read as: Under the top directory, get all packages.config files in all sub-directories.
The latest docs are at Microsoft here:
https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-select-the-files-to-build
This has nothing to do with paths in CMD or DOS. This is how MSBuild's wildcards work. You can read about them here. Basically, ** matches a partial path, so in your case the items include all packages.config from any subfolders of $(TopDir). (And $(TopDir) would be specified in some <PropertyGroup> elsewhere.)
I've got a directory containing multiple files that I want to include in my msi package build by a Wix project.
/database
/database/migration11.txt
/database/migration21.txt
/database/migration32.txt
Those files change often or there are new ones added, and I don't want to adapt my Wix file with every new migration file.
Basically I want to say in my wxs file to include all files in the directory database and upon installation put them in the directory [INSTALLLOCATION]/database.
Any way to achieve this?
ADDED:
Just found this workaround: use HEAT but I'm curious if there is another, recommended way.
You can use task in your wixproj file:
<ItemGroup>
... Your wxs files ...
<HarvestDirectory Include="$(variable)\YourDirectory\">
<ComponentGroupName>CG_YOUR_GROUP</ComponentGroupName>
<DirectoryRefId>DIR_REFERENCE</DirectoryRefId>
<AutogenerateGuids>false</AutogenerateGuids>
<GenerateGuidsNow>false</GenerateGuidsNow>
<SuppressUniqueIds>true</SuppressUniqueIds>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<SuppressRootDirectory>true</SuppressRootDirectory>
<PreprocessorVariable>var.Property_Preprocessor</PreprocessorVariable>
</HarvestDirectory>
</ItemGroup>
This task calls Heat during the build. Hope this helps you.
If anyone still needs this, here is a sample of HarvestDirector with wixproj. Thanks to DavidEGrayson.
I am looking for a very simple example that shows what exactly is and how to use the MSBuild Extension Pack: http://msbuildextensionpack.codeplex.com/ I just cannot find anything for a real beginner. Thank you.
Go through these Links,
They would be very useful, I figured out how to use MSBuildCommunityTasks through them,
How do I import the msbuildcommunitytasks project from another msbuild project with a relative file path?
Msbuild and SVN update
Also,
Example
<SvnUpdate
Username="$(CommitUser)"
Password="$(CommitPassword)"
LocalPath="$(ProjectDir)">
</SvnUpdate>
Its just what you use on the Command Line.
I have a msbuild target and it has a Import tag like this:
<Import Project="$(MSBuildExtensionsPath)\Company\Company.LifeCycle.targets" />
In contents of Company.LifeCycle.targets file, how can I get programatically the current directory (in this case is: C:\Program Files\MsBuild\Company) ??
I use VS 2008, .NET 3.5
Edit: I have seen the reference, How can I get current directory in msbuild script?, but not valid for me: $(MSBuildProjectDirectory give me this value, C:\Work\Company\Projects\Test001\ProyectSW3
With MSBuild 4 you can use the new property 'MSBuildThisFileDirectory' see my blog http://sedodream.com/2010/03/11/MSBuild40ReservedProperties.aspx. If you are not using MSBuild 4, you cannot do this easily.
Your question has already been answered in another post here: MsBuild: Get current directory of targets. I hope the answers there satisfy you.
You can pretty much use MSBuildProjectDirectory which will give you the path to your current project file and you can build upon that.
Please go easy I am new to msbuild and msbuildtasks!
How can I set a property which represents a relative file path to a targets file which I want to import? I need relative references so it will work on all dev machines. But the target for import is trying to use the relative file path internally, which won't work as it is re-evaluated relative to the imported target!
Effectively I am trying to work around the documented behaviour of imported projects:
All relative paths in imported
projects are interpreted relative to
the directory of the imported project.
Therefore, if a project file is
imported into several project files in
different locations, the relative
paths in the imported project file
will be interpreted differently for
each imported project.
There was a similar question at Is it possible to use MSBuild Extension Pack without installation?. That question was how to do the same with the MSBuild Extension Pack, both of which are similar in this aspect. For the Extension Pack you have to declare the property ExtensionTasksPath,and for the Community tasks you have to declare a similar property named MSBuildCommunityTasksLib. So in your case it should look like:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildCommunityTasksLib Condition="'$(MSBuildCommunityTasksLib)' == ''">E:\Data\Development\My Code\Community\MSBuild\CommunityTasks\</MSBuildCommunityTasksLib>
</PropertyGroup>
<Import Project="$(MSBuildCommunityTasksLib)MSBuild.Community.Tasks.Targets"/>
<Target Name="Demo">
<!-- Use the tasks here -->
</Target>
</Project>
Ok, I've found the answer. Essentially you have to set the property MSBuildCommunityTasksPath as a relative path back to the original containing directory.
For example, given a folder structure like this:
Root---project---Build---{My msbuild project}
|
|-Tools---MSBuildCommunityTasks---{Binaries and Targets}
Where :
{My msbuild project} is in Root\Project\Build\
{MSbuildCommunityTasks} is in Root\Project\Tools\MsBuildCommunityTasks
To get the targets project to reference its binaries via the property MSBuildCommunityTasksPath, it will find the tasks file like this:
<PropertyGroup>
<MSBuildCommunityTasksPath>..\MSBuildCommunityTasks\</MSBuildCommunityTasksPath> <!--Relative path back to yourself-->
</PropertyGroup>
Then you can import the targets file with another relative file reference :
<Import Project="..\..\Tools\MSBuildCommunityTasks\MsBuild.Community.Tasks.Targets"/>
#Sayed Ibrahim Hashimi
Talkin about MSBuild4
Just declaring the MSBuildCommunityTasksLib wont suffice cause if u check the MSBuild.Community.Tasks.Targets file the properties are declared as follows
<PropertyGroup>
<MSBuildCommunityTasksPath Condition="'$(MSBuildCommunityTasksPath)' == ''">$(MSBuildExtensionsPath)\MSBuildCommunityTasks</MSBuildCommunityTasksPath>
<MSBuildCommunityTasksLib>$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.dll</MSBuildCommunityTasksLib>
</PropertyGroup>
So if U only over ride the MSBuildCommunityTasksLib it will again get over ridden in the MSBuild.Community.Tasks.Targets file as it is not conditional
So u HAVE TO ALSO OVERRIDE MSBuildCommunityTasksPath so that its proerty is NOT SET FROM MSBuildExtensionsPath but from ur custom path.
Correst me if I m wrong
This appears to be one answer:
http://social.msdn.microsoft.com/forums/en-US/msbuild/thread/feb782e3-72ae-4476-9011-617796f217b6
But this (if I understand it correctly) appears to be a ridiculous solution. To get the paths to work I need to change the imported project references? What would happen if I wanted to reference the imported project from third project in another folder?!?
I'm a noob at msbuild if I'm quite honest however I've just solved my own problem I had with this. I was turning one of the targets into its own project and it wasn't finding the paths for the msbuild community paths. If you look at your original project you may find something like this
<PropertyGroup>
<ExtensionTasksPath>./</ExtensionTasksPath>
<MSBuildCommunityTasksPath>./</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="MSBuildExtensionPack\MSBuild.ExtensionPack.tasks"/>
<Import Project="MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
Copy this code into your new project and it should work.
I just wanted to add, since i cannot comment (rep), that to do a path to your particular project you can use $(SolutionDir) on your property group like so:
$(SolutionDir)\My Code\Community\MSBuild\CommunityTasks\
This way its not tied down to a specific drive and can be based off of the location of the project relative to your solutions directory structure.
Also thanks for the answer above it helped me in my project with the addition above.