Reputation: 375
I have the following code in a msbuild file.
<?xml version='1.0' encoding='ISO-8859-1' ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ExtensionImportPath Condition="Exists('$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks') AND '$(DOTNETFRAMEWORK)'!='3.5'">$(MSBuildExtensionsPath)\ExtensionPack\4.0\</ExtensionImportPath>
<ExtensionImportPath Condition="'$(ExtensionImportPath)' == ''">$(MSBuildExtensionsPath)\ExtensionPack\</ExtensionImportPath>
</PropertyGroup>
<Import Project="$(ExtensionImportPath)\MSBuild.ExtensionPack.tasks"/>
<PropertyGroup>
<CommonTop Condition="'$(CommonTop)'==''">.</CommonTop>
<Root>$(MSBuildProjectDirectory)</Root>
<SourceRoot>$(Root)</SourceRoot>
<OutputRoot>$(CommonTop)\bin</OutputRoot>
<OutputDebug>$(Root)\bin\Debug</OutputDebug>
</PropertyGroup>
<Target Name="compile">
<Message Condition="'$(verbose)'=='true'" Text="$(MSBuildProjectFullPath) - empty compile target"/>
</Target>
</Project>
That is used for all project. In each project I then have another msbuild project but I cant really get that to work ok. This is my code
<?xml version='1.0' encoding='ISO-8859-1' ?>
<Project DefaultTargets="Start" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<CommonTop>.</CommonTop>
<!-- Importera top msbuild-->
<Import Project="..\\ms_top.proj"/>
<Target Name="Start">
<ItemGroup>
<ProjectsToBuild Include="$(CommonTop)\bulidmyHelloProject\hello.csproj" />
</ItemGroup>
<PropertyGroup>
<PackageSubDir>myoutput\hello\Bin</PackageSubDir>
</PropertyGroup>
<Message Text="StartTest" />
</Target>
</Project>
I call it with this parameters: /t:compile /p:verbose=true /t:target=Start
but i get error:
CoreCompile:
ProjectsToBuild.Properties=
ProjectsToBuild.AdditionalProperties=
ProjectsToBuild=
C:\Build\hello_labb_\src\w32\msbuild.proj : error MSB4057: Target target=Start does not exist in project
I understand the error that it calls the first one but there is no target Start but how can I make it work? I dont want to add anything in the top msbuild file.
Upvotes: 0
Views: 462
Reputation: 3454
You are missing <PropertyGroup>
around your <CommonTop>.</CommonTop>
in the second snippet. Fix it and try - it's LGTM
Upvotes: 1