Raimonds
Raimonds

Reputation: 537

MSbuild run specific targets for specific projects

I am using following code in 2 our of 3 projects from the solution default target is set to PublishMe

<Target Name="PublishMe" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
    <Error Condition="'$(PublishDestination)'==''" Text="The PublishDestination property must be set to the intended publishing destination." />
    <MakeDir Condition="!Exists($(PublishDestination))" Directories="$(PublishDestination)" />
    <ItemGroup>
      <PublishFiles Include="$(_PackageTempDir)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(PublishFiles)" DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="True" />
</Target>

If I run msbuild it builds and publishes just as expected, the problem is that I can't build it from VS anymore, I am having error of missing projectname.dll

Is there way I can change default build target if it is msbuild doing build?

I tried to /t:ProjectName:target;ProjectName2:target, but it isn't working with custom targets for some reason.

Is there way I can specify param from msbuild console to run PublishMe target and if not present run simple build?

Upvotes: 1

Views: 159

Answers (1)

mystack
mystack

Reputation: 5492

You can usefollowing command

 msbuild projectname /t:targetname.

Also please check the below link for more info

Building a solution file using msbuild

Upvotes: 1

Related Questions