Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Support to enable <EmbedInteropTypes> for a nuget package
  • Loading branch information
ruhullahshah committed Jul 27, 2018
commit 6282a73e5e5dd0af5acb05fcdf3bbc2e14a84877
5 changes: 5 additions & 0 deletions docs/content/references-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ DotNetZip framework: >= net45
FSharp.Core redirects: on
```

## Adding support for COM interop DLL
Follows the same syntax as the previous one:
`PkgName embed_interop_types: true`
In case it is not enabled, the default behavior is to drop `<EmbedInteropTypes>` from the project file.

## Excluding libraries

This option allows you to exclude libraries from being referenced in project files:
Expand Down
10 changes: 7 additions & 3 deletions src/Paket.Core/PaketConfigFiles/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ module ProjectFile =
AnalyzersNode : XmlElement
}

let generateXml (model:InstallModel) (usedFrameworkLibs:HashSet<TargetProfile*string>) (aliases:Map<string,string>) (copyLocal:bool option) (specificVersion:bool option) (importTargets:bool) (referenceCondition:string option) (allTargetProfiles:Set<TargetProfile>) (project:ProjectFile) : XmlContext =
let generateXml (model:InstallModel) (usedFrameworkLibs:HashSet<TargetProfile*string>) (aliases:Map<string,string>) (embedInteropTypes:bool option) (copyLocal:bool option) (specificVersion:bool option) (importTargets:bool) (referenceCondition:string option) (allTargetProfiles:Set<TargetProfile>) (project:ProjectFile) : XmlContext =
let references =
getCustomReferenceAndFrameworkNodes project
|> List.map (fun node -> node.Attributes.["Include"].InnerText.Split(',').[0])
Expand Down Expand Up @@ -767,6 +767,10 @@ module ProjectFile =
| None -> n
| Some(bool) -> addChild (createNodeSet "SpecificVersion" specificVersionSettings project) n
|> addChild (createNodeSet "Paket" "True" project)
|> fun n ->
match embedInteropTypes with
| None -> n
| _ -> addChild (createNodeSet "EmbedInteropTypes" "True" project) n
|> fun n ->
match aliases with
| None -> n
Expand Down Expand Up @@ -1237,7 +1241,7 @@ module ProjectFile =
let importTargets = defaultArg installSettings.ImportTargets true

let allFrameworks = applyRestrictionsToTargets restrictionList KnownTargetProfiles.AllProfiles
generateXml projectModel usedFrameworkLibs installSettings.Aliases installSettings.CopyLocal installSettings.SpecificVersion importTargets installSettings.ReferenceCondition (set allFrameworks) project)
generateXml projectModel usedFrameworkLibs installSettings.Aliases installSettings.EmbedInteropTypes installSettings.CopyLocal installSettings.SpecificVersion importTargets installSettings.ReferenceCondition (set allFrameworks) project)

for ctx in contexts do
for chooseNode in ctx.ChooseNodes do
Expand Down Expand Up @@ -1726,7 +1730,7 @@ type ProjectFile with

member this.DeleteCustomModelNodes(model:InstallModel) = ProjectFile.deleteCustomModelNodes model this

member this.GenerateXml(model, usedFrameworkLibs:HashSet<TargetProfile*string>, aliases, copyLocal, specificVersion, importTargets, allTargetProfiles:#seq<TargetProfile>, referenceCondition) = ProjectFile.generateXml model usedFrameworkLibs aliases copyLocal specificVersion importTargets referenceCondition (set allTargetProfiles) this
member this.GenerateXml(model, usedFrameworkLibs:HashSet<TargetProfile*string>, aliases, embedInteropTypes, copyLocal, specificVersion, importTargets, allTargetProfiles:#seq<TargetProfile>, referenceCondition) = ProjectFile.generateXml model usedFrameworkLibs aliases embedInteropTypes copyLocal specificVersion importTargets referenceCondition (set allTargetProfiles) this

member this.RemovePaketNodes () = ProjectFile.removePaketNodes this

Expand Down
7 changes: 4 additions & 3 deletions src/Paket.Core/PaketConfigFiles/ReferencesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ type ReferencesFile =
{ ReferencesFile.FromLines lines with FileName = fileName }
with e -> raise (new Exception(sprintf "Could not parse reference file '%s': %s" fileName e.Message, e))

member this.AddNuGetReference(groupName, packageName : PackageName, copyLocal: bool, specificVersion: bool, importTargets: bool, frameworkRestrictions, includeVersionInPath, downloadLicense, omitContent : bool, createBindingRedirects, referenceCondition) =
member this.AddNuGetReference(groupName, packageName : PackageName, embedInteropTypes: bool, copyLocal: bool, specificVersion: bool, importTargets: bool, frameworkRestrictions, includeVersionInPath, downloadLicense, omitContent : bool, createBindingRedirects, referenceCondition) =
let package: PackageInstallSettings =
{ Name = packageName
Settings =
{ CopyLocal = if not copyLocal then Some copyLocal else None
{ EmbedInteropTypes = if embedInteropTypes then Some embedInteropTypes else None
CopyLocal = if not copyLocal then Some copyLocal else None
SpecificVersion = if not specificVersion then Some specificVersion else None
CopyContentToOutputDirectory = None
StorageConfig = None
Expand Down Expand Up @@ -172,7 +173,7 @@ type ReferencesFile =
{ this with Groups = newGroups }

member this.AddNuGetReference(groupName, packageName : PackageName) =
this.AddNuGetReference(groupName, packageName, true, true, true, ExplicitRestriction FrameworkRestriction.NoRestriction, false, false, false, None, null)
this.AddNuGetReference(groupName, packageName, false, true, true, true, ExplicitRestriction FrameworkRestriction.NoRestriction, false, false, false, None, null)

member this.RemoveNuGetReference(groupName, packageName : PackageName) =
let group = this.Groups.[groupName]
Expand Down
8 changes: 7 additions & 1 deletion src/Paket.Core/Versioning/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ type InstallSettings =
LicenseDownload: bool option
ReferenceCondition : string option
CreateBindingRedirects : BindingRedirectsSettings option
EmbedInteropTypes : bool option
CopyLocal : bool option
SpecificVersion : bool option
StorageConfig : PackagesFolderGroupConfig option
Expand All @@ -892,7 +893,8 @@ type InstallSettings =
GenerateLoadScripts : bool option }

static member Default =
{ CopyLocal = None
{ EmbedInteropTypes = None
CopyLocal = None
SpecificVersion = None
StorageConfig = None
ImportTargets = None
Expand Down Expand Up @@ -1046,6 +1048,10 @@ type InstallSettings =
| x -> failwithf "Unknown copy_content_to_output_dir settings: %A" x
Excludes = []
Aliases = Map.empty
EmbedInteropTypes =
match getPair "embed_interop_types" with
| Some "true" -> Some true
| _ -> None
CopyLocal =
match getPair "copy_local" with
| Some "false" -> Some false
Expand Down