Using MSBuild to compile WPF User Controls - c#

I am trying to use MSBuild to compile WPF user controls into a library. In a test project I get the results I expected to, however in my active project I have run into nothing but problems.
This being the first time I have used MSBuild I created a test project to figure out how to use it. I added references to Microsoft.Build and Microsoft.Build.Engine, using the code below my program did exactly what I wanted. The library compiled and I was able to load and use the usercontrol as intended.
MSBuild C#
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
namespace MSBuildTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void RunButton_Click(object sender, RoutedEventArgs e)
{
string fileName = #"C:\...\MSBuildTest.proj";
ProjectCollection buildEngin = new ProjectCollection();
Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();
GlobalProperty.Add("Configuration", "Release");
GlobalProperty.Add("Platform", "x86");
BuildRequestData BuildRequest = new BuildRequestData(fileName, GlobalProperty, null, new string[] { "Build" }, null);
var buildParameters = new BuildParameters(buildEngin);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, BuildRequest);
}
}
}
.proj file
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<OutputType>Library</OutputType>
<OutputPath>someoutputpath</OutputPath>
<Assembly>MSBuildTest.dll</Assembly>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Page Include="C:\...\UserControl1.xaml" />
<Compile Include="C:\...\UserControl1.xaml.cs" >
<DependentUpon>UserControl1.xaml</DependentUpon>
</Compile>
<Reference Include="System" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
</ItemGroup>
<Import Project="$(MsbuildBinPath)\Microsoft.CSharp.targets" />
</Project>
UserControl .xaml
<UserControl x:Class="UserControlTest.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:UserControlTest"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="Button" Click="Button_Click" />
<TextBlock Grid.Row="1" x:Name="TextBlock1" Background="White" Text="{Binding ElementName=TextBlock2, Path=Text}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="Test" Background="White" />
</Grid>
</UserControl>
UserControl .cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace UserControlTest
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : System.Windows.Controls.UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("This worked");
}
}
}
I switched over to my main program to start implementing my new toy. I followed the same steps I did in my test project. I ran the program expecting it to work exactly as the test program had, but I got this exception:
"System.BadImageFormatException: 'Could not load file or assembly
'Microsoft.Build, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. Reference assemblies cannot be
loaded for execution. (0x80131058)'" I compared the projects and
found that the test project I started was targeting .NET Framework
4.7.2 while my main project targeted .NET 7.0.
After research I found that with .Net 7.0 I should be using the MSBuild NuGet Package instead of referencing the MSBuild dlls.
So, I made the appropriate changes to my projects and tried running it again. The build fails and I get this exception:
The SDK 'Microsoft.NET.Sdk' specified could not be found.
More digging and I find that setting the "MSBuildSDKsPath" environment variable allows MSBuild to find the SDK. But the build fails again
with this exception:
“The imported project
"…MainProgram\bin\x64\Debug\net7.0-windows\Current\Microsoft.Common.props"
was not found. Confirm that the expression in the Import declaration
"…MainProgram\bin\x64\Debug\net7.0-windows\Current\Microsoft.Common.props"
is correct, and that the file exists on disk. C:\Program
Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props”
Setting the "AlternateCommonProps" environment variable appropriately
solved that problem, but:
“The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified
could not be found. C:\Program
Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props”
Given that I wasn’t making much progress this way I decided to try out
the Microsoft.Build.Locator. I made the appropriate changes to my
program. Using the locator, the program correctly finds the SDK
without having to set environments variables, which is nice. However,
my builds still fail and now all the exceptions are blank. I added a
logger to see if I can figure out what is going on. Below are some of
the warnings and errors I received and through changes to the .proj
file was able to get past with varying degrees of success.
Project "MSBuiltTest.proj" (Build target(s)): Warning C:\Program
Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3):
"C:\Program Files\dotnet\sdk\7.0.101\Microsoft.Common.targets" cannot
be imported again. It was already imported at "C:\Program
Files\dotnet\sdk\7.0.101\Microsoft.CSharp.CurrentVersion.targets
(327,5)". This is most likely a build authoring error. This subsequent
import will be ignored. […\MSBuiltTest.proj] Done building project
"MSBuiltTest.proj" -- FAILED.
Project "MSBuiltTest.proj" (Build target(s)):
GetReferenceAssemblyPaths: : ERROR C:\Program
Files\dotnet\sdk\7.0.101\Microsoft.Common.CurrentVersion.targets(1229,5):
The reference assemblies for .NETFramework,Version=v4.0 were not
found. To resolve this, install the Developer Pack (SDK/Targeting
Pack) for this framework version or retarget your application. You can
download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks Project "MSBuiltTest.proj"
(Build target(s)): ResolveAssemblyReference: : Warning C:\Program
Files\dotnet\sdk\7.0.101\Microsoft.Common.CurrentVersion.targets(2352,5):
Could not resolve this reference. Could not locate the assembly
"System". Check to make sure the assembly exists on disk. If this
reference is required by your code, you may get compilation errors.
ResolveAssemblyReference: : …"WindowsBase"…
ResolveAssemblyReference: : …" PresentationCore "…
ResolveAssemblyReference: : …" PresentationFramework "…
ResolveAssemblyReference: : …" PresentationFramework "…
ResolveAssemblyReference: : …" System.Xaml "…
ResolveAssemblyReference: : Warning C:\Program
Files\dotnet\sdk\7.0.101\Microsoft.Common.CurrentVersion.targets(2352,5):
No way to resolve conflict between "System, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System".
Choosing "System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" arbitrarily.
ResolveAssemblyReference: : …"WindowsBase, …
ResolveAssemblyReference: : …" PresentationCore "…
ResolveAssemblyReference: : …" PresentationFramework "…
ResolveAssemblyReference: : …" PresentationFramework "…
ResolveAssemblyReference: : …" System.Xaml "… Done building project
"MSBuiltTest.proj" -- FAILED.
Project "MSBuiltTest.proj" (Build target(s)): ERROR C:\Program
Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(211,9):
The "MarkupCompilePass1" task was not given a value for the required
parameter "Language". Done building project "MSBuiltTest.proj" --
FAILED.
The test project I built worked exactly as I had hoped it would, but my main program is continuously giving me grief. It’s my hope that I am missing some simple solution to my problems. But I have read everything I can find on how to use MSBuild, I have followed the endless rabbit trails of .common and .prop files and have even spent time digging through the MSBuild source code. The conclusion I have come to is that it’s turtles all the way down. Can someone tell me what I am missing or point me in the direction of some documentation that can help?

Related

UWP FullTrustProcessLauncher gives "Element not found" exception on launch

I have a solution in visual studio containing a Windows Application Packaging Project, a UWP project, and a Console Application project. The UWP app contains a single button that when pressed is supposed to launch the console application as a fulltrust process. Solution Explorer looks like this:
The Windows Application Packaging project is set as the startup project. It's entry point is set to the UWP app. Both the UWP app and the console app are added to the packaging project as references.
Configuration manager looks like this:
The console app is set as a dependency for the UWP app. The dependencies for the UWP app looks like this:
The build order look like this:
Code
Here is the code for the console app:
using System;
using System.Diagnostics;
namespace ShellHost
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
As I mentioned the UWP app only has one page (MainPage.xaml) and it's code behind looks like this:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.ApplicationModel;
namespace OnScreenDeviceManager
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private async void button_Click(object sender, RoutedEventArgs e)
{
await FullTrustProcessLauncher.LaunchFullTrustProcessForAppAsync("Default");
}
}
}
The manifest for the UWP app is unmodified. The manifest for the Package has been modified to include fulltrust capability, and it contains the necessary extension for the fulltrust process. The xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
IgnorableNamespaces="uap rescap desktop">
<Identity
Name="d3e964dc-9265-4243-b97c-2dacb7c11dac"
Publisher="CN=Dell"
Version="1.0.0.0" />
<Properties>
<DisplayName>Package</DisplayName>
<PublisherDisplayName>Dell</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="Package"
Description="Package"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<desktop:Extension Category="windows.fullTrustProcess" Executable="ShellHost\ShellHost.exe">
<desktop:FullTrustProcess>
<desktop:ParameterGroup GroupId="SyncGroup" Parameters="/Sync"/>
<desktop:ParameterGroup GroupId="OtherGroup" Parameters="/Other"/>
<desktop:ParameterGroup GroupId="Default" Parameters=""/>
</desktop:FullTrustProcess>
</desktop:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient"/>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
The package/debug/bin folder where the solution exe resides looks like this:
You can clearly see the console app exe (ShellHost.exe) in the ShellHost folder.
The console app has been tested and works just fine. The UWP app works just fine except when I click the button I get an 'Element not found' exception.
Exception message says:
System.Exception: 'Element not found. (Exception from HRESULT: 0x80070490)'
This exception was originally thrown at this call stack:
[External Code]
OnScreenDeviceManager.MainPage.button_Click(object, Windows.UI.Xaml.RoutedEventArgs) in MainPage.xaml.cs
Can anyone help me solve this? What am I missing?
LaunchFullTrustProcessForAppAsync API means you need to launch the full-trust process with the specified application ID.
I suggest you try to use LaunchFullTrustProcessForCurrentAppAsync(String) API to replace your code.
private async void button_Click(object sender, RoutedEventArgs e)
{
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("Default");
}

C# Class System.Data.SqlClient can not load file or assembly

How do I use the SqlClient directive with .NET Standard 2.0?
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
Having great difficulty with Visual Studio at the minute, when I run my program I am greeted with the following exception:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.SqlClient, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
Resulting in the application not running, the directive has been installed via NuGet and my class .csproj looks like:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
</ItemGroup>
</Project>
The Form's framewwork is set to .NET framework 4.6.1...
I can not change the class framework to match, and I am not sure if this is causing the error?
The methods - that are causing the error - referenced from the Class:
//Connect to Database
public void Connection()
{
try
{
// Create SqlConnection
connString = "Data Source = xx; Initial Catalog = xx; User ID = xx; Password = xx";
con = new SqlConnection(connString);
con.Open();
}
catch (Exception ex)
{
string error;
error = ex.ToString();
}
}
Option 1) You might have already tried this.
Remove the reference & add it manually.
Option 2) Somehow System.Data.SqlClient dll is missing from your output or build folder
So, try adding post build script.
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy ..\..\..\packages\System.Data.SqlClient\runtimes\win\lib\netstandard2.0\System.Data.SqlClient.dll bin\Debug\appname\" Condition="'$(IsWindows)' == 'true'" />
<Exec Command="cp ../../../packages/System.Data.SqlClient/runtimes/unix/lib/netstandard2.0/System.Data.SqlClient.dll bin/Debug/appname/" Condition="'$(IsWindows)' != 'true'" />
</Target>

"Validation error. error C00CE014: App manifest validation error" when trying to create app packages for Windows Store

I'm struggling with this error for a few hours now. I can build and deploy the app without issues, it just won't create distributable packages (Project > Store > Create App Packages)
The problem is rather weird. Here's my Package.appxmanifest file:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap mp uap3">
<Identity Name="481f1dca-fa19-4642-8e95-9208a4c9265f" Publisher="CN=mrrey" Version="1.1.8.0" />
<mp:PhoneIdentity PhoneProductId="06509575-8d8e-4beb-aa84-4ea390365781" PhonePublisherId="06509575-8d8e-4beb-aa84-4ea390365785" />
<Properties>
<DisplayName>XYZ MusicBox</DisplayName>
<PublisherDisplayName>mrrey</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="XYZ_MusicBox.App">
<uap:VisualElements DisplayName="XYZ MusicBox" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="XYZ MusicBox" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="musicLibrary" />
<uap3:Capability Name="backgroundMediaPlayback" />
<DeviceCapability Name="microphone" />
</Capabilities>
</Package>
This is the initial state of my manifest. After I click Create in the wizard, it starts building the packages. The output:
...
1> 1018 ms Csc 2 calls
1> 1091 ms ResolveAssemblyReference 1 calls
1> 3498 ms CompileXaml 2 calls
1> 3615 ms GenerateAppxManifest 1 calls
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:11.30
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Package: 0 succeeded, 1 failed ===========
========== App Bundle: 0 succeeded, 1 failed ===========
After that, when I try to open the Package.appxmanifest file the designer doesn't want to load due to the compiler error:
Severity Code Description Project File Line Suppression State
Error Validation error. error C00CE014: App manifest validation error: The app manifest must be valid as per schema: Line 34, Column 6, Reason: Element 'Capability' is unexpected according to content model of parent element '{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Capabilities'. Expecting: {http://schemas.microsoft.com/appx/manifest/foundation/windows10}CapabilityChoice, {http://schemas.microsoft.com/appx/manifest/foundation/windows10}DeviceCapability. XYZ MusicBox C:\Users\mrrey\Box Sync\XYZ MusicBox\XYZ MusicBox\bin\x86\Debug\AppxManifest.xml
The weirdest part of it all is the fact that during creating the package VS is modifying my original appxmanifest file and adding this line to the capabilities:
<Capability Name="backgroundMediaPlayback" xmlns="" />
As you can see in the code above, I already have this capability added, but it requires a uap3: namespace to work correctly. For some reason it still forces this one, though. And what's with that xmlns attribute with an empty value?
After attempting packages creation I'm also getting a number of warnings like this one:
Severity Code Description Project File Line Suppression State
Warning Imported schema for namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3' was not resolved. XYZ MusicBox C:\Users\mrrey\Box Sync\XYZ MusicBox\XYZ MusicBox\Package.appxmanifest 17
Everything works correctly when I remove the original Background Media Playback capability, but that's not something I can afford since it's a media player app.There's clearly something wrong with this capability/project's configuration but I can't find it.
This doesn't happen when I just build the solution and deploy the app to Local Machine/Device/Emulators.
I'm using up-to-date Visual Studio 2017 and Windows 10 (Version 10.0.14393 Build 14393).
Did anyone encounter a similar issue? Am I doing something wrong or is it a bug?
Thank you!
Edit: To make things even clearer: these short warnings (Imported schema for namespace...) are referring to <Applications>, <Application>, <Properties> and <Dependencies> tags.
Edit2: I don't even wanna think about this anymore. Somehow I broke it even more.

Spring.NET ObjectDefinitionStoreException using assembly to store configuration files

I am learning Spring.Net, I created a class MyApplication and a library class MyLib with all the spring configuration files that MyApplication needs.
I retrieve the metadata using:
IApplicationContext ctx = new XmlApplicationContext("assembly...");
I have three different xml files, one (springconfiguration.xml) imports the two other. At the beginning of my tries, my spring configuration files were at the root level of MyLib. Everything worked fine.
----- MyLib
-- Properties
-- References
-- commonspring.xml
-- buttonspring.xml
-- springconfiguration.xml
Then I created some folders in MyLib to store my xml files and it fails if I use subfolders:
the following works:
----- MyLib
--Properties
--References
--Common
--commonspring.xml
--Gui
--buttonspring.xml
--Configuration
--springconfiguration.xml
my springconfiguration.xml file is then:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<import resource="Common/commonspring.xml"/>
<import resource="Gui/buttonspring.xml"/>
</objects>
and I retrieve the context with:
IApplicationContext ctx = new XmlApplicationContext("assembly://MyLib/MyLib/Configuration.springconfiguration.xml");
but if I use subfolders then it fails:
----- MyLib
--Properties
--References
--Common
--commonspring.xml
--Gui
--SpecialButton
--buttonspring.xml
--Configuration
--springconfiguration.xml
my springconfiguration.xml file is then:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<import resource="Common/commonspring.xml"/>
<import resource="Gui/SpecialButton/buttonspring.xml"/>
</objects>
and I retrieve the context with:
IApplicationContext ctx = new XmlApplicationContext("assembly://MyLib/MyLib/Configuration.springconfiguration.xml");
The error is:
{"Error registering object defined in 'assembly [MyLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null], resource [MyLib.Configuration.springconfiguration.xml] at line 5' : Invalid relative resource location 'Gui/SpecialButton/buttonspring.xml' to import object definitions from.\r\n<import resource=\"Gui/SpecialButton/buttonspring.xml\" xmlns=\"http://www.springframework.net\" />"}
I tried several syntaxes, I looked in the documentation and did not find any solution. Has someone an idee of where is the problem?
Update
ok I found by myself: the correct syntaxe is:
<import resource="Gui.SpecialButton.buttonspring.xml"/>
then no errors are raised anymore and everything work fine.
To let everybody know here is the solution I found: in springconfiguration.xml instead of refering to the spring configuration file nested in folders as:
<import resource="Gui/SpecialButton/buttonspring.xml"/>
One has to write:
<import resource="Gui.SpecialButton.buttonspring.xml"/>
#marijn: thank you for your explanation, understanding a solution is better than just finding it ;)

How do I use regular expressions with Nant 0.91 calling a C#

In Nant 0.85 you could call C# scripts and it would import the System.Text.RegularExpressions namespace. Now in 0.91 that is no longer the case, and I can't seem to to import System.Text.RegularExpressions properly. I've tried adding the following
<imports>
<import namespace="System.Text.RegularExpressions" />
</imports>
And I see System.Text.RegularExpressions get added to a using statement, but I keep getting the error:
The type or namespace name 'RegularExpressions' does not exist in the
namespace 'System.Text' (are you missing an assembly reference?)
You need to add a reference to System.dll:
<references>
<include name="System.dll" />
</references>

Categories