diff --git a/DotNetWorker.sln b/DotNetWorker.sln
index 877c8f53b..5ce4a5f11 100644
--- a/DotNetWorker.sln
+++ b/DotNetWorker.sln
@@ -70,6 +70,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Sdk", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Sdk.Tests", "test\Azure.Functions.Sdk.Tests\Azure.Functions.Sdk.Tests.csproj", "{CB71124E-019E-4A81-882B-D96DCF574C37}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Sdk.Resolver", "test\Azure.Functions.Sdk.Resolver\Azure.Functions.Sdk.Resolver.csproj", "{BC2EF124-0868-4FCC-A711-DB4C1C860CB8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -160,6 +162,10 @@ Global
{CB71124E-019E-4A81-882B-D96DCF574C37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB71124E-019E-4A81-882B-D96DCF574C37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB71124E-019E-4A81-882B-D96DCF574C37}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BC2EF124-0868-4FCC-A711-DB4C1C860CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BC2EF124-0868-4FCC-A711-DB4C1C860CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BC2EF124-0868-4FCC-A711-DB4C1C860CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BC2EF124-0868-4FCC-A711-DB4C1C860CB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -188,6 +194,7 @@ Global
{750993F6-4E3B-411B-9471-74CEA4F9C23A} = {E785547C-7546-469F-827C-FDF999D5D7E8}
{02CBCC67-A10C-4064-AA5D-84533AC02342} = {083592CA-7DAB-44CE-8979-44FAFA46AEC3}
{CB71124E-019E-4A81-882B-D96DCF574C37} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
+ {BC2EF124-0868-4FCC-A711-DB4C1C860CB8} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {497D2ED4-A13E-4BCA-8D29-F30CA7D0EA4A}
diff --git a/src/Azure.Functions.Sdk/Azure.Functions.Sdk.csproj b/src/Azure.Functions.Sdk/Azure.Functions.Sdk.csproj
index 1b3376823..948d4f06a 100644
--- a/src/Azure.Functions.Sdk/Azure.Functions.Sdk.csproj
+++ b/src/Azure.Functions.Sdk/Azure.Functions.Sdk.csproj
@@ -40,6 +40,9 @@
+
@@ -54,13 +57,16 @@
-
-
+
+
<_SdkFilesTemp Include="@(None->WithMetadataValue('SdkFile', 'true'))" />
+ <_SdkFilesTemp Include="@(BuildOutputInPackage)" PackagePath="tools/netstandard2.0/%(BuildOutputInPackage.TargetPath)" />
-
+
diff --git a/test/Azure.Functions.Sdk.Resolver/Azure.Functions.Sdk.Resolver.csproj b/test/Azure.Functions.Sdk.Resolver/Azure.Functions.Sdk.Resolver.csproj
new file mode 100644
index 000000000..e1841b7d9
--- /dev/null
+++ b/test/Azure.Functions.Sdk.Resolver/Azure.Functions.Sdk.Resolver.csproj
@@ -0,0 +1,36 @@
+
+
+
+ netstandard2.0
+ latest
+ enable
+ enable
+ false
+ $(SrcRoot)Azure.Functions.Sdk/Azure.Functions.Sdk.csproj
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_SdkFiles Include="@(_ResolverAssemblyFullPath)" PackagePath="%(Filename)%(Extension)" />
+ <_SdkFiles Update="@(_SdkFiles)" TargetPath="resolver/$(AssemblyName)/%(PackagePath)" />
+
+
+
+
+
diff --git a/test/Azure.Functions.Sdk.Resolver/README.md b/test/Azure.Functions.Sdk.Resolver/README.md
new file mode 100644
index 000000000..8f3cdd774
--- /dev/null
+++ b/test/Azure.Functions.Sdk.Resolver/README.md
@@ -0,0 +1,32 @@
+# Azure.Functions.Sdk.Resolver
+
+This project scaffolds out a custom `Microsoft.Build.Framework.SdkResolver` which will automatically resolve the `Azure.Functions.Sdk/99.99.99` SDK for integration testing.
+
+To use this, you must scaffold out the contents as follows:
+
+```
+-
+ |- Azure.Functions.Sdk.Resolver
+ |- Azure.Functions.Sdk.Resolver.dll
+ |- sdk/*
+ |- targets/*
+ |- build/*
+ |- tools/*
+```
+
+You then set the environment variable `MSBUILDADDITIONALSDKRESOLVERSFOLDER=`.
+
+To use from another project, like a test project, simply reference the project. Consider adding `ReferenceOutputAssembly="false"` as the dll is not directly needed.
+
+``` xml
+
+
+
+```
+
+The resolver will be scaffolded out to `$(OutDir)/resolver`. Use the resolver by setting the appropriate environment variable:
+
+``` csharp
+string resolverPath = Path.Combine(Path.GetDirectoryName(typeof(SomeTypeInTestAssembly).Assembly.Location)!, "resolver");
+Environment.SetEnvironmentVariable("MSBUILDADDITIONALSDKRESOLVERSFOLDER", resolverPath); // Set this before evaluating your project via MSBuild APIs.
+```
diff --git a/test/Azure.Functions.Sdk.Resolver/TestSdkResolver.cs b/test/Azure.Functions.Sdk.Resolver/TestSdkResolver.cs
new file mode 100644
index 000000000..f6fdc1a20
--- /dev/null
+++ b/test/Azure.Functions.Sdk.Resolver/TestSdkResolver.cs
@@ -0,0 +1,26 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Microsoft.Build.Framework;
+
+namespace Azure.Functions.Sdk.Resolver;
+
+public class TestSdkResolver : SdkResolver
+{
+ private static readonly string SdkPath = Path.Combine(
+ Path.GetDirectoryName(typeof(TestSdkResolver).Assembly.Location), "sdk");
+
+ public override string Name => "Test Azure Functions SDK Resolver";
+
+ public override int Priority => 1000;
+
+ public override SdkResult Resolve(SdkReference sdkReference, SdkResolverContext context, SdkResultFactory factory)
+ {
+ if (sdkReference.Name == "Azure.Functions.Sdk")
+ {
+ return factory.IndicateSuccess(SdkPath, "99.99.99"); // test version.
+ }
+
+ return factory.IndicateFailure([]);
+ }
+}
diff --git a/test/Azure.Functions.Sdk.Tests/Azure.Functions.Sdk.Tests.csproj b/test/Azure.Functions.Sdk.Tests/Azure.Functions.Sdk.Tests.csproj
index 83a4dfc1b..242a0dc64 100644
--- a/test/Azure.Functions.Sdk.Tests/Azure.Functions.Sdk.Tests.csproj
+++ b/test/Azure.Functions.Sdk.Tests/Azure.Functions.Sdk.Tests.csproj
@@ -6,15 +6,18 @@
latest
enable
enable
- $(SrcRoot)Azure.Functions.Sdk/Azure.Functions.Sdk.csproj
+ ../Azure.Functions.Sdk.Resolver/Azure.Functions.Sdk.Resolver.csproj
+
+
-
+
+
@@ -40,14 +43,4 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/test/Azure.Functions.Sdk.Tests/Integration/MSBuildExtensions.cs b/test/Azure.Functions.Sdk.Tests/Integration/MSBuildExtensions.cs
index 9e0cd7845..6c76569d9 100644
--- a/test/Azure.Functions.Sdk.Tests/Integration/MSBuildExtensions.cs
+++ b/test/Azure.Functions.Sdk.Tests/Integration/MSBuildExtensions.cs
@@ -11,16 +11,12 @@ namespace Azure.Functions.Sdk.Tests.Integration;
internal static class MSBuildExtensions
{
- private static readonly string ThisAssemblyDirectory =
- Path.GetDirectoryName(typeof(MSBuildExtensions).Assembly.Location)!;
-
private static readonly ImmutableDictionary DefaultGlobalProperties =
ImmutableDictionary.CreateRange(
[
KeyValuePair.Create("ImportDirectoryBuildProps", bool.FalseString),
KeyValuePair.Create("ImportDirectoryPackagesProps", bool.FalseString),
KeyValuePair.Create("ImportDirectoryBuildTargets", bool.FalseString),
- KeyValuePair.Create("AzureFunctionsSdkTasksAssembly", Path.Combine(ThisAssemblyDirectory, "Azure.Functions.Sdk.dll")),
KeyValuePair.Create("RestoreSources", "https://api.nuget.org/v3/index.json" )
]);
@@ -35,12 +31,11 @@ public static ProjectCreator AzureFunctionsProject(
return ProjectCreator.Create(
path: path,
projectCollection: projectCollection,
+ sdk: "Azure.Functions.Sdk/99.99.99",
globalProperties: GetGlobalProperties(globalProperties))
- .Import(Path.Combine(ThisAssemblyDirectory, "sdk", "sdk", "Sdk.props"))
.PropertyGroup()
.Property("TargetFramework", targetFramework)
- .CustomAction(configure)
- .Import(Path.Combine(ThisAssemblyDirectory, "sdk", "sdk", "Sdk.targets"));
+ .CustomAction(configure);
}
public static ProjectCreator WriteSourceFile(
diff --git a/test/Azure.Functions.Sdk.Tests/Integration/SdkEndToEndTests.Restore.cs b/test/Azure.Functions.Sdk.Tests/Integration/SdkEndToEndTests.Restore.cs
index 7a0623c17..925ca382b 100644
--- a/test/Azure.Functions.Sdk.Tests/Integration/SdkEndToEndTests.Restore.cs
+++ b/test/Azure.Functions.Sdk.Tests/Integration/SdkEndToEndTests.Restore.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
-using AwesomeAssertions;
using Microsoft.Build.Utilities.ProjectCreation;
namespace Azure.Functions.Sdk.Tests.Integration;
diff --git a/test/Azure.Functions.Sdk.Tests/LogMessageTests.cs b/test/Azure.Functions.Sdk.Tests/LogMessageTests.cs
index 6b8adb81b..81bd92400 100644
--- a/test/Azure.Functions.Sdk.Tests/LogMessageTests.cs
+++ b/test/Azure.Functions.Sdk.Tests/LogMessageTests.cs
@@ -4,7 +4,6 @@
using System.Collections;
using System.Globalization;
using System.Resources;
-using AwesomeAssertions;
using NuGet.Common;
namespace Azure.Functions.Sdk.Tests;
diff --git a/test/Azure.Functions.Sdk.Tests/ModuleInitializer.cs b/test/Azure.Functions.Sdk.Tests/ModuleInitializer.cs
index 9fa072713..ce4f21fd4 100644
--- a/test/Azure.Functions.Sdk.Tests/ModuleInitializer.cs
+++ b/test/Azure.Functions.Sdk.Tests/ModuleInitializer.cs
@@ -1,32 +1,25 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
-
-
using System.Runtime.CompilerServices;
-using AwesomeAssertions;
using Microsoft.Build.Utilities.ProjectCreation;
namespace Azure.Functions.Sdk.Tests;
internal static class ModuleInitializer
{
+ private static readonly string ResolverPath = Path.Combine(
+ Path.GetDirectoryName(typeof(ModuleInitializer).Assembly.Location)!, "resolver");
+
///
/// We cannot include MSBuild assemblies in our output, because they will interfere with
/// MSBuilds assembly scanning. Instead we use the MSBuildLocator to resolve them at runtime.
///
[ModuleInitializer]
- internal static void InitializeMSBuild()
+ internal static void Initialize()
{
+ Environment.SetEnvironmentVariable("MSBUILDADDITIONALSDKRESOLVERSFOLDER", ResolverPath);
MSBuildAssemblyResolver.Register();
- }
-
- ///
- /// Bootstrap our custom formatters for AwesomeAssertions at startup.
- ///
- [ModuleInitializer]
- internal static void InitializeFormatters()
- {
FormatterResolver.Initialize();
}
}