0

I have a tool which I want to deliver via nuget. I'm not very familiar with it, but what I read so far is that you can define dependencies with conditions. Can the condition also be a environment variable?

I found this here:

<ItemGroup>
    <!-- ... -->
    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" Condition="'$(TargetFramework)' == 'net452'" />
    <!-- ... -->
</ItemGroup>

What are there for other "variables" in like in the example above the TargetFramework?

There are also two dependencies which contains what I need, how can I say that I need one of them and not both? And how can I define which I want if nothing is installed yet?

rekire
  • 47,260
  • 30
  • 167
  • 264

1 Answers1

1

Yes, you can use Environment Variable in Condition:

Use a Condition attribute on a property to set the value only if the property has no value. For example, the following code sets the ToolsPath property to c:\tools only if the ToolsPath environment variable is not set:

<ToolsPath Condition="'$(TOOLSPATH)' == ''">c:\tools</ToolsPath>

Source: How to: Use environment variables in a build

List of all MSBuild build-in properties can be found here: https://stackoverflow.com/a/1453023/7225096

Peska
  • 3,980
  • 3
  • 23
  • 40