crash application after bulid from msbuild - c#

this is my first post on stackoverflow. When I build my WPF, .NET40 project from VS 2013 (F6 key) application run fine, but when i use msbuild to automatic build and deploy my applications, then always i have crash on start.
My msbuid code:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="default">
<PropertyGroup>
<BaseDir>$(MSBuildProjectDirectory)</BaseDir>
<BinariesDir>$(MSBuildProjectDirectory)\mui\1.0\FirstFloor.ModernUI\Build\Binaries</BinariesDir>
<OutputDir>$(MSBuildProjectDirectory)\Setup\BuildResults\net4</OutputDir>
<Configuration Condition="'$(Configuration)'==''" >Release</Configuration>
<Platform Condition="'$(Platform)'==''">x86</Platform>
<PlatformTarget Condition="'$(PlatformTarget)'==''">x86</PlatformTarget>
<AllowUnsafeBlocks Condition="'$(AllowUnsafeBlocks)'==''">true</AllowUnsafeBlocks>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)'==''">v4.0</TargetFrameworkVersion>
<DefineConstants Condition="'$(DefineConstants)'==''">TRACE;NET4</DefineConstants>
<OutputPath Condition="'$(OutputPath)'==''">bin\AutoBuild\$(platform)\</OutputPath>
<MSBuildExtensions>$(BinariesDir)\MSBuild.Community.Tasks.dll</MSBuildExtensions>
<!--<SolutionFile>$(BaseDir)\Charon.sln</SolutionFile>-->
<SolutionFile>$(BaseDir)\cmu\cmu.csproj</SolutionFile>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<UsingTask AssemblyFile="$(MSBuildExtensions)" TaskName="MSBuild.Community.Tasks.XmlUpdate" />
<UsingTask AssemblyFile="$(MSBuildExtensions)" TaskName="MSBuild.Community.Tasks.Zip" />
<Target Name="default" DependsOnTargets="Clean; Compile" />
<Target Name="Clean">
<!-- clear output dir -->
<RemoveDir Directories="$(OutputDir)" />
</Target>
<Target Name="Compile">
<MSBuild
Projects="$(SolutionFile)"
Targets="Clean;Build"
Properties="
Configuration=$(Configuration);
Platform=$(Platform);
PlatformTarget=$(PlatformTarget);
AllowUnsafeBlocks=$(AllowUnsafeBlocks);
TargetFrameworkVersion=$(TargetFrameworkVersion);
DefineConstants=$(DefineConstants);
OutputPath=$(OutputDir)"/>
</Target>
</Project>
and bat file, use to run msbuild:
#echo off
set msBuild=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
set innoSetup="%programfiles(x86)%\Inno Setup 5\iscc.exe"
rem Charon applications bulid version
set /a bulidVersion=(%date:~0,4%-2011)*12+%date:~5,2%
set appVersion=2.0.%bulidVersion%%date:~8,2%
rem MarcorpUpdater buid version AsmVersionMarcorpUpdater
set /a bulidVersion=(%date:~0,4%-2014)*12+%date:~5,2%
set marcorpUpdaterBuiltVersion = 1.0.%bulidVersion%%date:~8,2%
#echo on
rem call %msBuild% cmu\cmu.csproj /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net45;PlatformTarget=x86;TargetFrameworkVersion=v4.5;DefineConstants="NET45;TRACE";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=cmu_Manual_MSBuild_LOG.net45.log /t:Rebuild
rem call %msBuild% charon\charon.cspro`enter code here`j /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net45;PlatformTarget=x86;TargetFrameworkVersion=v4.5;DefineConstants="NET45;TRACE";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=charon_Manual_MSBuild_LOG.net45.log /t:Rebuild
rem call %msBuild% cmu\cmu.csproj /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net4;PlatformTarget=x86;TargetFrameworkVersion=v4.0;DefineConstants="TRACE;NET4";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=cmu_Manual_MSBuild_LOG.net4.log /t:Rebuild
call %msBuild% build.msbuild /p:AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=cmu_Manual_MSBuild_LOG.net4.log
pause
rem call %msBuild% charon\charon.csproj /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net4;PlatformTarget=x86;TargetFrameworkVersion=v4.0;DefineConstants="NET4;TRACE";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=charon_Manual_MSBuild_LOG.net4.log /t:Rebuild
rem call %innoSetup% Setup\setup.iss "/dMyAppVersion=%appVersion%"
#echo off
set msBuild=
set innoSetup=
set appVersion=
set bulidVersion=
set marcorpUpdaterBuiltVersion=
Crash:
Application: net.marcorp.charon.modernui.exe
Framework version: v4.0.30319
Description: The process was terminated due to an unhandled exception..
Exception Info: System.Windows.Markup.XamlParseException
Stack:
at: System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at: System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri) at: System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at: System.Windows.Application.LoadComponent(System.Object, System.Uri)
at: net.marcorp.charon.modernui.App.InitializeComponent()
at: net.marcorp.charon.modernui.App.Main()

Related

Setting a version number, by setting a PropertyGroup, a project variable in the csproj file

I am trying to set the version number to something I want (read they want me to do).
They want a specific format, and I need to set the version of out programme.
I tried to use a UsingTask to set a PropertyGroup variable. My UsingTask is working.
All this is new to me, I managed to get the code below. Now, how can I set the local project variable?
My initial value is used, next I want to set it programmatically in the UsingTask
This is all done in the *.csproj file
<Project Sdk="Microsoft.NET.Sdk">
<!-- my additional project variable, used below -->
<PropertyGroup Label="UserMacros">
<AssemblyVersion>1.2.3.5</AssemblyVersion>
</PropertyGroup>
<UsingTask TaskName="EnvVarSet"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
// here I want to set the version number to our format
Log.LogMessage(MessageImportance.High, "**** Setting variables");
System.Environment.SetEnvironmentVariable("AssemblyVersion", "1.5.6.7");
var a = Environment.GetEnvironmentVariable("AssemblyVersion");
Log.LogMessage(MessageImportance.High, "**** Value is: " +a);
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!-- the version number I want to set -->
<Version>$(AssemblyVersion)</Version>
<!-- this does not work -->
<!-- <Version>$([System.Environment]::GetEnvironmentVariable('AssemblyVersion'))</Version>-->
other values....
</PropertyGroup>
//more project....
<Target Name="BeforeBeforeBuild" BeforeTargets="BeforeBuild">
<EnvVarSet />
<Message Text="***** AssemblyVersionis now: $([System.Environment]::GetEnvironmentVariable('AssemblyVersion'))"/>
</Target>
</Project>
You can view the document https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build.
You can do this by using the dotnct command. Use multiple doctnct commands to pass the version number to each command and build the project and all its dependencies via dotnet build-.
You can use the following command to help you set the version number: dotnet build /p:AssemblyVersion=1.2.3.4
I managed to get what I want.
Here is my example of how to do the classic Build and Revision autoincrement numbers in the assembly version
This is an example, I was asked to do another format, but one can create any format this way
First, add the AssemblyVersion
<PropertyGroup>
<!-- add this line -->
<AssemblyVersion>1.0.0.0</AssemblyVersion>
And add this code, which is similar to "1.2.*" in .Net Framework
<Target Name="BeforeBeforeBuild" BeforeTargets="BeforeBuild">
<SetBuildNumber>
<Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion" />
</SetBuildNumber>
</Target>
<UsingTask TaskName="SetBuildNumber" TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<AssemblyVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage(MessageImportance.High, "Setting version number");
var now = DateTime.Now;
var secondsSinceMidnightDivivedBy2 = (int)(now - now.Date).TotalSeconds / 2;
var daysSinceJan1st2000 = (int)(now - new DateTime(2000, 1, 1)).TotalDays;
AssemblyVersion = "1.2." +
daysSinceJan1st2000.ToString() + "." +
secondsSinceMidnightDivivedBy2.ToString();
Log.LogMessage(MessageImportance.High, "Version number is: " + AssemblyVersion);
]]>
</Code>
</Task>
</UsingTask>
In the code above, one can set the assembly version to what may be required
The code above give a custom assembly version to the final exe or dll file, but for some reason it does not work, when the installer publishes the project to one file, in the "pre-build event command line":
dotnet publish $(SolutionDir)NCAutomatedReport\NCAutomatedReport.csproj
-p:PublishProfile=FolderProfile -r:win10-x64 -p:PublishSingleFile=true
-p:PublishReadyToRun=false -p:PublishTrimmed=false -c:Release
-o:$(TargetDir)published
This gives the error
The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild.
and
The task factory "CodeTaskFactory" could not be loaded from the assembly
"C:\Program Files\dotnet\sdk\6.0.400\Microsoft.Build.Tasks.Core.dll".
The task factory must return a value for the "TaskType" property.
Now I should look into this - any ideas anyone?

How to add custom compiled file (in Target/Exec) as resource in .csproj's?

I'm doing a few shadereffects in a wpf_c# project and i don't know and i didn't find how to add the bytecode pixelshader (.ps) as Resource after be compiled by a target/exec. This is my csproj code fragment:
<ItemGroup>
<AvailableItemName Include="PixelShader"/>
</ItemGroup>
<ItemGroup>
<PixelShader Include="Shaders\BlueToneShader.fx" />
bla bla bla other shaders bla bla
</ItemGroup>
<Target Name="PixelShaderCompile" Condition="#(PixelShader)!=''" BeforeTargets="Build">
<Exec Command=""C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\fxc.exe" %(PixelShader.Identity) /T ps_3_0 /E main /Fo%(PixelShader.RelativeDir)%(PixelShader.Filename).ps" />
</Target>
Everything goes fine and the .ps files are correctly generated, as example:
PixelShaderCompile:
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\fxc.exe" Shaders\BlueToneShader.fx /T ps_3_0 /E main /FoShaders\BlueToneShader.ps
Microsoft (R) Direct3D Shader Compiler 10.1 Copyright (C) 2013 Microsoft. All rights reserved.
compilation object save succeeded; see "folder"...
But now i dont know how to add that .ps file as 'Resource' during the compilation. Any one knows how? I didn't find any clear documentation.
After 3-4 hours of trial-error i found a (i think dirty) way to do it: the msbuild (.csproj) looks like:
<PropertyGroup>
<BuildDependsOn>
PixelShaderCompile
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>
<ItemGroup>
<AvailableItemName Include="PixelShader">
<Visible>true</Visible>
</AvailableItemName>
</ItemGroup>
<ItemGroup>
<PixelShader ... />
...
</ItemGroup>
<Target Name="PixelShaderCompile" Condition="#(PixelShader)!=''" BeforeTargets="BeforeBuild;BeforeRebuild">
<MakeDir Directories="$(IntermediateOutputPath)%(PixelShader.RelativeDir)" Condition="!Exists('$(IntermediateOutputPath)%(PixelShader.RelativeDir)')" />
//You put your fxc.exe command here
<Exec Command=""C:\bla bla bla\fxc.exe" %(PixelShader.Identity) /T ps_3_0 /E PSmain /O3 /Fo$(IntermediateOutputPath)%(PixelShader.RelativeDir)%(PixelShader.Filename).ps" Outputs="$(IntermediateOutputPath)%(PixelShader.RelativeDir)%(PixelShader.Filename).ps">
<Output ItemName="CompiledPixelShader" TaskParameter="Outputs" />
</Exec>
<ItemGroup>
<Resource Include="#(CompiledPixelShader)" />
</ItemGroup>
</Target>
//If you want to clear the .ps generated file
<Target Name="PixelShaderClean" Condition="#(PixelShader)!=''" AfterTargets="AfterBuild;AfterRebuild">
<Delete Files="$(IntermediateOutputPath)%(PixelShader.RelativeDir)%(PixelShader.Filename).ps" />
</Target>
That's it... So hard because there aren't so many made examples of msbuild files.

Change assembly name for build settings in .csproj

I have an application which I want to publish with ClickOnce via command line. I have a test and a live version. It should be allowed to have both installed at the same time, which means that I need to change the assemble name (and preferably also the product name) for one of the builds. I would like to do this in the build settings.
I have managed to make some build settings, which works fine, but I cannot figure out how to change the assembly and product name, for just one of them.
I have added the following code to my .csproj file, which I call with the command msbuild /target:Test or msbuild /target:Live. But where do I implement the assembly and product name change?
<PropertyGroup>
<ProjLocation>$(ProjectDir)</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Debug</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<DeploymentFolder>C:\MyProjects\Software\Publish\</DeploymentFolder>
</PropertyGroup>
<!-- Build settings for live version -->
<Target Name="Live" DependsOnTargets="Clean">
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Publish"/>
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*"/>
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(SetupFiles)" DestinationFolder="$(DeploymentFolder)\Live\" />
<Copy SourceFiles="#(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Live\Application Files\%(RecursiveDir)"/>
</Target>
<!-- Build settings for test version -->
<Target Name="Test" DependsOnTargets="Clean">
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Publish"/>
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*"/>
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(SetupFiles)" DestinationFolder="$(DeploymentFolder)\Public Test\" />
<Copy SourceFiles="#(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Public Test\Application Files\%(RecursiveDir)"/>
</Target>
You can add "AssemblyName" property to the PropertyGroup. like this:
<PropertyGroup>
<AssemblyName>YourAppName</AssemblyName>
</PropertyGroup>
or you can use the MSBuild command line switch. like this :
msbuild /property:AssemblyName=YourAppName
I had almost the same task (need to distinguish between Staging and Production) and I solved it with the following MSBuild-Target:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- call "nuget restore Deployment\packages.config" before executing this script -->
<Import Project="..\packages\MSBuildTasks.1.5.0.235\build\MSBuildTasks.targets" />
<PropertyGroup>
<Configuration>Release</Configuration>
<ClientProject>..\MyProject\MyProject.vbproj</ClientProject>
<ClientPublishDir Condition="$(Environment) == 'Staging'">\\deployment-staging\MyProject\</ClientPublishDir>
<ClientPublishDir Condition="$(Environment) == 'Production'">\\deployment\MyProject\</ClientPublishDir>
</PropertyGroup>
<ItemGroup>
<ClientModifiedAppConfig Include="$(ClientProject)\..\App.$(Environment).config" />
</ItemGroup>
<Target Name="DeployClient">
<Error Condition="$(Environment) == ''" Text="The Property 'Environment' has not been set." />
<Error Condition="$(Environment) != 'Staging' AND $(Environment) != 'Production'" Text="The Property 'Environment' has not been set properly. Valid values are 'Staging' and 'Production'." />
<!-- Sets different assembly names for INT and PRD applications. Due to this, both INT and PRD applications with the
same version number can be installed on the same system. -->
<XmlUpdate Condition="$(Environment) == 'Staging'" Prefix="n" Namespace="http://schemas.microsoft.com/developer/msbuild/2003" XmlFileName="$(ClientProject)" Xpath="/n:Project/n:PropertyGroup/n:AssemblyName" Value="MyProjectStaging" />
<XmlUpdate Condition="$(Environment) == 'Staging'" Prefix="n" Namespace="http://schemas.microsoft.com/developer/msbuild/2003" XmlFileName="$(ClientProject)" Xpath="/n:Project/n:PropertyGroup/n:ProductName" Value="MyProject Staging" />
<XmlUpdate Condition="$(Environment) == 'Production'" Prefix="n" Namespace="http://schemas.microsoft.com/developer/msbuild/2003" XmlFileName="$(ClientProject)" Xpath="/n:Project/n:PropertyGroup/n:AssemblyName" Value="MyProject" />
<XmlUpdate Condition="$(Environment) == 'Production'" Prefix="n" Namespace="http://schemas.microsoft.com/developer/msbuild/2003" XmlFileName="$(ClientProject)" Xpath="/n:Project/n:PropertyGroup/n:ProductName" Value="MyProject" />
<!-- Overwrites the original App.config with the environment-dependent App.config.
Reason: ClickOnce only uses App.config and does not apply transformations, as it is done in Web Projects. -->
<Copy
SourceFiles="#(ClientModifiedAppConfig)"
DestinationFiles="$(ClientProject)\..\App.config"
OverwriteReadOnlyFiles="true"
/>
<!-- Publish -->
<MSBuild
Projects="$(ClientProject)"
Targets="Publish"
Properties="
PublishDir=$(ClientPublishDir);
Configuration=$(Configuration);
Platform=x86" />
</Target>
</Project>
To make this work, you have to restore the NuGet package MSBuildTasks.
Finally, all I have to call is msbuild Deployment.targets /t:DeployClient /p:Environment=Staging
Hope that helps!

Extract MSBuild Parameter

I have an MSBuild file like this:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Param1>Hello world</Param1>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Param1>Goodbye world</Param1>
</PropertyGroup>
</Project>
I am working on an external application and I need to be able to find out what the configured value of Param1 is. I need a way to correctly evaluate the MSBuild file so that any conditions are applied and then the correct parameter returned to the calling application.
Being able to do something like this would be great:
>MSBuild /p:Configuration=Release MyBuild.proj -extractParam:Param1
>Goodbye World
Any ideas? Is this possible with C# instead?
You can make the project output the value, then parse it using scripting/C#/....
Add this target to your project:
<Target Name="OutputParam1" AfterTargets="Build">
<Message Text="Param1 = $(Param1)"/>
</Target>
it will be invoked automatically after the Build target.
Then on the commandline:
>MSBuild /p:Configuration=Release MyBuild.proj /fl
where /fl cause the file msbuild.log to be generated, which will contain amongst others a line
Param1 = Goodbye world
because of the Message task. Now use e.g. powershell to output the matching part:
>powershell -command "$a = Select-String -Path msbuild.log -Pattern 'Param1 = (.+)'; $a.Matches[0].Groups[1].Value"
>Goodbye world
You can add a target which prints the param value:
<Target Name="ExtractParam1" >
<Message Text="$(Param1)" Importance="high" />
</Target>
The switches /v:m /nologo makes the output print just the value:
msbuild /p:Configuration=Release MyBuild.proj /t:ExtractParam1 /v:m /nologo

How can I set the LIB environment variable inside a csproj file?

I'm operating on a system where the environment variable LIB is set to "--must-override--". I cannot change the value of the variable on the system itself.
In Visual Studio, the LIB variable is checked during compilation. Because it's set to a junk value, I get a warning in the build:
Invalid search path '--must-override--' specified in 'LIB environment variable' -- 'The system cannot find the path specified.
I'd like to get rid of this warning. To do so, I need to override the value of the LIB environment variable that VS uses, either to NULL or to some value pointing to a real path.
Since I can't change the value of the variable in the environment, I need to do it within the csproj file itself. I've tried setting it in a property group to no avail:
<PropertyGroup>
<Lib></Lib>
</PropertyGroup>
Any ideas on how this variable can be set? Or if it's even possible?
You can mangle it in using the Exec Task, or you can write your own Task to set them - here's the "Let's mangle away with Exec" route:
<PropertyGroup>
<!--
need the CData since this blob is just going to
be embedded in a mini batch file by studio/msbuild
-->
<LibSetter><![CDATA[
set Lib=C:\Foo\Bar\Baz
set AnyOtherEnvVariable=Hello!
]]></LibSetter>
</PropertyGroup>
<Exec Command="$(LibSetter)" />
EDIT:
So I just threw this csproj together with the basics - I've confirmed they do set properly when I run them - I've added in the inline-Task approach as well.
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask
TaskName="EnvVarSet"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<VarName ParameterType="System.String" Required="true"/>
<VarValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
Console.WriteLine("Setting var name {0} to {1}...", VarName, VarValue);
System.Environment.SetEnvironmentVariable(VarName, VarValue);
Console.WriteLine("{0}={1}", VarName, VarValue);
]]>
</Code>
</Task>
</UsingTask>
<Target Name="ThingThatNeedsEnvironmentVars">
<CallTarget Targets="FiddleWithEnvironmentVars"/>
<Message Text="LIB environment var is now: $([System.Environment]::GetEnvironmentVariable('LIB'))"/>
</Target>
<Target Name="FiddleWithEnvironmentVars">
<Message Text="LIB environment var is now: $([System.Environment]::GetEnvironmentVariable('LIB'))"/>
<EnvVarSet VarName="LIB" VarValue="C:\temp"/>
<Message Text="LIB environment var is now: $([System.Environment]::GetEnvironmentVariable('LIB'))"/>
</Target>
</Project>

Categories