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?

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.