Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of wildcard AssemblyVersion properties during markup compilation #2691

Merged
merged 15 commits into from
Apr 1, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -2596,7 +2596,20 @@ private void GenerateInitializeComponent(bool isApp)

string uriPart = string.Empty;

string version = String.IsNullOrEmpty(AssemblyVersion) ? String.Empty : COMPONENT_DELIMITER + VER + AssemblyVersion;
// If we have an actual version string, try to detect wildcards. Note that this is required to be at least major.minor.
// Prior to markup compilation, this will have been validated by the C# compiler.
bool wildcardUsed = false;

if (!string.IsNullOrEmpty(AssemblyVersion))
{
var splitVersion = AssemblyVersion.Split('.');
wildcardUsed = splitVersion[splitVersion.Length - 1] == "*";
rladuca marked this conversation as resolved.
Show resolved Hide resolved
}

// If a developer explicitly sets the AssemblyVersion build property to a wildcard version string, we would use that as part of the URI here.
rladuca marked this conversation as resolved.
Show resolved Hide resolved
// This results in an error in Version.Parse during InitializeComponent's call tree. Instead, do as we would have when the developer sets a
// wildcard version string via AssemblyVersionAttribute and use an empty string.
string version = (String.IsNullOrEmpty(AssemblyVersion) || wildcardUsed) ? String.Empty : COMPONENT_DELIMITER + VER + AssemblyVersion;
string token = String.IsNullOrEmpty(AssemblyPublicKeyToken) ? String.Empty : COMPONENT_DELIMITER + AssemblyPublicKeyToken;
uriPart = FORWARDSLASH + AssemblyName + version + token + COMPONENT_DELIMITER + COMPONENT + FORWARDSLASH + resourceID;

Expand Down