Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Azure.Functions.Sdk/LogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static readonly LogMessage Error_InvalidExtensionPackageVersion
public static readonly LogMessage Warning_EndOfLifeFunctionsVersion
= new(nameof(Strings.AZFW0104_Warning_EndOfLifeFunctionsVersion));

public static readonly LogMessage Error_UsingLegacyFunctionsSdk
= new(nameof(Strings.AZFW0105_Error_UsingLegacyFunctionsSdk));
public static readonly LogMessage Error_UsingIncompatibleSdk
= new(nameof(Strings.AZFW0105_Error_UsingIncompatibleSdk));

public static readonly LogMessage Error_UnknownFunctionsVersion
= new(nameof(Strings.AZFW0106_Error_UnknownFunctionsVersion));
Expand Down Expand Up @@ -82,7 +82,7 @@ public static LogMessage FromId(string id)
nameof(Warning_ExtensionPackageDuplicate) => Warning_ExtensionPackageDuplicate,
nameof(Error_InvalidExtensionPackageVersion) => Error_InvalidExtensionPackageVersion,
nameof(Warning_EndOfLifeFunctionsVersion) => Warning_EndOfLifeFunctionsVersion,
nameof(Error_UsingLegacyFunctionsSdk) => Error_UsingLegacyFunctionsSdk,
nameof(Error_UsingIncompatibleSdk) => Error_UsingIncompatibleSdk,
nameof(Error_UnknownFunctionsVersion) => Error_UnknownFunctionsVersion,
nameof(Warning_UnsupportedTargetFramework) => Warning_UnsupportedTargetFramework,
_ => throw new ArgumentException($"Log message with id '{id}' not found.", nameof(id)),
Expand Down
4 changes: 2 additions & 2 deletions src/Azure.Functions.Sdk/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
<data name="AZFW0104_Warning_EndOfLifeFunctionsVersion" xml:space="preserve">
<value>Azure Functions '{0}' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/azure-functions-retired-versions for more information on the support policy.</value>
</data>
<data name="AZFW0105_Error_UsingLegacyFunctionsSdk" xml:space="preserve">
<value>Microsoft.NET.Sdk.Functions package is meant to be used with in-proc function apps. Please remove the reference to this package.</value>
<data name="AZFW0105_Error_UsingIncompatibleSdk" xml:space="preserve">
<value>'{0}'' package is incompatible with Azure.Functions.Sdk. Please remove the '{0}' package reference.</value>
</data>
<data name="AZFW0106_Error_UnknownFunctionsVersion" xml:space="preserve">
<value>The AzureFunctionsVersion '{0}' is unknown or not supported.</value>
Expand Down
5 changes: 3 additions & 2 deletions src/Azure.Functions.Sdk/Targets/Azure.Functions.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
Resource="Warning_UnsupportedTargetFramework" Arguments="$(TargetFramework)" />
</Target>

<Target Name="_FunctionAppValidation" DependsOnTargets="_ValidateFunctionsVersion" BeforeTargets="Restore;Build" >
<FuncSdkLog Condition="'$(_IsFunctionsSdkBuild)' == 'true'" Resource="Error_UsingLegacyFunctionsSdk" />
<Target Name="_CheckForConflictingFunctionSdk" BeforeTargets="CollectPackageReferences;Build">
<FuncSdkLog Condition="'%(PackageReference.Identity)' == 'Microsoft.Azure.Functions.Worker.Sdk'" Resource="Error_UsingIncompatibleSdk" Arguments="Microsoft.Azure.Functions.Worker.Sdk" />
<FuncSdkLog Condition="'%(PackageReference.Identity)' == 'Microsoft.NET.Sdk.Functions'" Resource="Error_UsingIncompatibleSdk" Arguments="Microsoft.NET.Sdk.Functions" />
</Target>

<Target Name="_FunctionsCheckForCoreTools">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ public void Restore_Incremental_NoOp()
hash.LastWriteTimeUtc.Should().Be(hashWrite);
}

[Theory]
[InlineData("Microsoft.NET.Sdk.Functions")]
[InlineData("Microsoft.Azure.Functions.Worker.Sdk")]
public void Restore_IncompatibleSdk_Fails(string package)
{
// Arrange
ProjectCreator project = ProjectCreator.Templates.AzureFunctionsProject(
GetTempCsproj())
.ItemPackageReference(package, "1.0.0");

// Act
BuildOutput output = project.Restore();

// Assert
output.Should().BeFailed()
.And.HaveNoWarnings()
.And.HaveSingleError()
.Which.Should().BeSdkMessage(
(LogMessage.Error_UsingIncompatibleSdk, package))
.And.HaveSender("FuncSdkLog");
}

private void ValidateProject(params NugetPackage[] packages)
{
ValidateProjectContents(packages);
Expand Down
Loading