MSBuild project won't load if Import fails?
Asked Answered
C

1

13

I created a build target in a project file (App.Tests.csproj) that imports a project:

 <Import Project ="$(Location)\Special.Tasks"/>

These tasks only exist on our build server, that location does not exist on our developers work station. The build target will ever only be run from the build server.

My problem is that when I try to open the sln (containing the project with the build target) on a workstation without the Special.Tasks the project won't load.

I don't want to distribute the Special.Tasks to each workstation.

Is there any way to tell MSBuild or Visual Studio to load even if an import fails?

Crawfish answered 2/3, 2011 at 16:32 Comment(1)
Thanks for getting an answer to this! In my case, it was a problem because my project depended on a .targets file provided by a nuget package that would only be installed as part of the build.Shirelyshirey
M
23

Just add condition to the Import target

<Import Project ="$(Location)\Special.Tasks"
        Condition="Exists('$(Location)\Special.Tasks')"/>
Mccaleb answered 2/3, 2011 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.