Skip to content

Commit 85de61f

Browse files
committed
Update folder structure
1 parent 1b067ab commit 85de61f

22 files changed

Lines changed: 617 additions & 220 deletions
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>annotations</Nullable>
8+
9+
<IsPackable>false</IsPackable>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<Compile Remove="Resources\MySamplePlugin\MySamplePlugin\bin\**" />
14+
<Compile Remove="Resources\MySamplePlugin\MySamplePlugin\obj\**" />
15+
<EmbeddedResource Remove="Resources\MySamplePlugin\MySamplePlugin\bin\**" />
16+
<EmbeddedResource Remove="Resources\MySamplePlugin\MySamplePlugin\obj\**" />
17+
<None Remove="Resources\MySamplePlugin\MySamplePlugin\bin\**" />
18+
<None Remove="Resources\MySamplePlugin\MySamplePlugin\obj\**" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.12.6" />
23+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
24+
<PackageReference Include="Moq" Version="4.20.72" />
25+
<PackageReference Include="MSTest.TestAdapter" Version="3.7.1" />
26+
<PackageReference Include="MSTest.TestFramework" Version="3.7.1" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<ProjectReference Include="..\Obsidian.MSBuild\Obsidian.MSBuild.csproj" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<Folder Include="Resources\" />
35+
<None Include="Resources\**\*.*" CopyToOutputDirectory="Always"/>
36+
</ItemGroup>
37+
38+
</Project>

Obsidian.MSBuild.Tests/PackTest.cs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using Microsoft.Build.Framework;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Moq;
4+
using System.Security.Cryptography;
5+
using System.Text;
6+
7+
namespace Obsidian.MSBuild.Test;
8+
9+
[TestClass]
10+
public class PackTest
11+
{
12+
private Mock<IBuildEngine> buildEngine;
13+
private List<BuildErrorEventArgs> errors;
14+
15+
[TestInitialize()]
16+
public void Startup()
17+
{
18+
this.buildEngine = new();
19+
this.errors = [];
20+
this.buildEngine.Setup(x => x.LogErrorEvent(It.IsAny<BuildErrorEventArgs>())).Callback<BuildErrorEventArgs>(e => errors.Add(e));
21+
}
22+
23+
[TestMethod]
24+
public void Pack_Success()
25+
{
26+
var packTask = new Pack
27+
{
28+
PluginApiVersion = "1.0.0",
29+
PluginId = "obsidianteam.mysampleplugin",
30+
PluginAssembly = "MySamplePluginTemplate",
31+
PluginAuthors = "ObsidianTeam",
32+
PluginVersion = "1.0.0",
33+
PluginPublishDir = ".\\Resources\\",
34+
PluginDependencies = [],
35+
BuildEngine = this.buildEngine.Object
36+
};
37+
38+
var success = packTask.Execute();
39+
40+
Assert.IsTrue(success);
41+
Assert.IsTrue(File.Exists(packTask.PackedFile));
42+
43+
File.Delete(packTask.PackedFile);
44+
}
45+
46+
[TestMethod]
47+
public void Pack_Read_Success()
48+
{
49+
var packTask = new Pack
50+
{
51+
PluginApiVersion = "1.0.0",
52+
PluginId = "obsidianteam.mysampleplugin",
53+
PluginAssembly = "MySamplePluginTemplate",
54+
PluginAuthors = "ObsidianTeam",
55+
PluginVersion = "1.0.0",
56+
PluginPublishDir = ".\\Resources\\",
57+
PluginDependencies = [],
58+
BuildEngine = this.buildEngine.Object
59+
};
60+
61+
var success = packTask.Execute();
62+
63+
Assert.IsTrue(success);
64+
Assert.IsTrue(File.Exists(packTask.PackedFile));
65+
66+
using var file = File.OpenRead(packTask.PackedFile);
67+
using var reader = new BinaryReader(file);
68+
69+
var headerId = Encoding.ASCII.GetString(reader.ReadBytes(4));
70+
var apiVersion = reader.ReadString();
71+
72+
var assemblyName = reader.ReadString();
73+
var version = reader.ReadString();
74+
var id = reader.ReadString();
75+
var authors = reader.ReadString();
76+
var description = reader.ReadString();
77+
78+
var hash = reader.ReadBytes(SHA384.HashSizeInBytes);
79+
var signed = reader.ReadBoolean();
80+
var dataLength = reader.ReadInt32();
81+
var entryCount = reader.ReadInt32();
82+
83+
Assert.AreEqual("OBBY", headerId);
84+
Assert.AreEqual("1.0.0", apiVersion);
85+
86+
Assert.AreEqual("MySamplePluginTemplate", assemblyName);
87+
Assert.AreEqual("1.0.0", version);
88+
89+
Assert.AreEqual("obsidianteam.mysampleplugin", id);
90+
Assert.AreEqual("ObsidianTeam", authors);
91+
Assert.AreEqual("No description provided", description);
92+
93+
Console.WriteLine($"Hash: {Convert.ToHexString(hash)}");
94+
Console.WriteLine($"Data Length: {dataLength}");
95+
96+
Assert.IsFalse(signed);
97+
Assert.AreEqual(9, entryCount);
98+
99+
File.Delete(packTask.PackedFile);
100+
}
101+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
"runtimeTarget": {
3+
"name": ".NETCoreApp,Version=v9.0",
4+
"signature": ""
5+
},
6+
"compilationOptions": {},
7+
"targets": {
8+
".NETCoreApp,Version=v9.0": {
9+
"MySamplePluginTemplate/1.0.0": {
10+
"dependencies": {
11+
"Microsoft.Extensions.Logging": "9.0.0",
12+
"Microsoft.Extensions.Logging.Abstractions": "9.0.0",
13+
"Obsidian.API": "1.0.0-nightly-46"
14+
},
15+
"runtime": {
16+
"MySamplePluginTemplate.dll": {}
17+
}
18+
},
19+
"Microsoft.CodeAnalysis.Analyzers/3.3.4": {},
20+
"Microsoft.CodeAnalysis.Common/4.11.0": {
21+
"dependencies": {
22+
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
23+
"System.Collections.Immutable": "8.0.0",
24+
"System.Reflection.Metadata": "8.0.0"
25+
}
26+
},
27+
"Microsoft.Extensions.DependencyInjection/9.0.0": {
28+
"dependencies": {
29+
"Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
30+
},
31+
"runtime": {
32+
"lib/net9.0/Microsoft.Extensions.DependencyInjection.dll": {
33+
"assemblyVersion": "9.0.0.0",
34+
"fileVersion": "9.0.24.52809"
35+
}
36+
}
37+
},
38+
"Microsoft.Extensions.DependencyInjection.Abstractions/9.0.0": {
39+
"runtime": {
40+
"lib/net9.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
41+
"assemblyVersion": "9.0.0.0",
42+
"fileVersion": "9.0.24.52809"
43+
}
44+
}
45+
},
46+
"Microsoft.Extensions.Logging/9.0.0": {
47+
"dependencies": {
48+
"Microsoft.Extensions.DependencyInjection": "9.0.0",
49+
"Microsoft.Extensions.Logging.Abstractions": "9.0.0",
50+
"Microsoft.Extensions.Options": "9.0.0"
51+
},
52+
"runtime": {
53+
"lib/net9.0/Microsoft.Extensions.Logging.dll": {
54+
"assemblyVersion": "9.0.0.0",
55+
"fileVersion": "9.0.24.52809"
56+
}
57+
}
58+
},
59+
"Microsoft.Extensions.Logging.Abstractions/9.0.0": {
60+
"dependencies": {
61+
"Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
62+
}
63+
},
64+
"Microsoft.Extensions.Options/9.0.0": {
65+
"dependencies": {
66+
"Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0",
67+
"Microsoft.Extensions.Primitives": "9.0.0"
68+
},
69+
"runtime": {
70+
"lib/net9.0/Microsoft.Extensions.Options.dll": {
71+
"assemblyVersion": "9.0.0.0",
72+
"fileVersion": "9.0.24.52809"
73+
}
74+
}
75+
},
76+
"Microsoft.Extensions.Primitives/9.0.0": {
77+
"runtime": {
78+
"lib/net9.0/Microsoft.Extensions.Primitives.dll": {
79+
"assemblyVersion": "9.0.0.0",
80+
"fileVersion": "9.0.24.52809"
81+
}
82+
}
83+
},
84+
"Obsidian.API/1.0.0-nightly-46": {
85+
"dependencies": {
86+
"Microsoft.CodeAnalysis.Common": "4.11.0",
87+
"Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0",
88+
"Microsoft.Extensions.Logging.Abstractions": "9.0.0",
89+
"SharpNoise": "0.12.1.1"
90+
}
91+
},
92+
"SharpNoise/0.12.1.1": {},
93+
"System.Collections.Immutable/8.0.0": {},
94+
"System.Reflection.Metadata/8.0.0": {
95+
"dependencies": {
96+
"System.Collections.Immutable": "8.0.0"
97+
}
98+
}
99+
}
100+
},
101+
"libraries": {
102+
"MySamplePluginTemplate/1.0.0": {
103+
"type": "project",
104+
"serviceable": false,
105+
"sha512": ""
106+
},
107+
"Microsoft.CodeAnalysis.Analyzers/3.3.4": {
108+
"type": "package",
109+
"serviceable": true,
110+
"sha512": "sha512-AxkxcPR+rheX0SmvpLVIGLhOUXAKG56a64kV9VQZ4y9gR9ZmPXnqZvHJnmwLSwzrEP6junUF11vuc+aqo5r68g==",
111+
"path": "microsoft.codeanalysis.analyzers/3.3.4",
112+
"hashPath": "microsoft.codeanalysis.analyzers.3.3.4.nupkg.sha512"
113+
},
114+
"Microsoft.CodeAnalysis.Common/4.11.0": {
115+
"type": "package",
116+
"serviceable": true,
117+
"sha512": "sha512-djf8ujmqYImFgB04UGtcsEhHrzVqzHowS+EEl/Yunc5LdrYrZhGBWUTXoCF0NzYXJxtfuD+UVQarWpvrNc94Qg==",
118+
"path": "microsoft.codeanalysis.common/4.11.0",
119+
"hashPath": "microsoft.codeanalysis.common.4.11.0.nupkg.sha512"
120+
},
121+
"Microsoft.Extensions.DependencyInjection/9.0.0": {
122+
"type": "package",
123+
"serviceable": true,
124+
"sha512": "sha512-MCPrg7v3QgNMr0vX4vzRXvkNGgLg8vKWX0nKCWUxu2uPyMsaRgiRc1tHBnbTcfJMhMKj2slE/j2M9oGkd25DNw==",
125+
"path": "microsoft.extensions.dependencyinjection/9.0.0",
126+
"hashPath": "microsoft.extensions.dependencyinjection.9.0.0.nupkg.sha512"
127+
},
128+
"Microsoft.Extensions.DependencyInjection.Abstractions/9.0.0": {
129+
"type": "package",
130+
"serviceable": true,
131+
"sha512": "sha512-+6f2qv2a3dLwd5w6JanPIPs47CxRbnk+ZocMJUhv9NxP88VlOcJYZs9jY+MYSjxvady08bUZn6qgiNh7DadGgg==",
132+
"path": "microsoft.extensions.dependencyinjection.abstractions/9.0.0",
133+
"hashPath": "microsoft.extensions.dependencyinjection.abstractions.9.0.0.nupkg.sha512"
134+
},
135+
"Microsoft.Extensions.Logging/9.0.0": {
136+
"type": "package",
137+
"serviceable": true,
138+
"sha512": "sha512-crjWyORoug0kK7RSNJBTeSE6VX8IQgLf3nUpTB9m62bPXp/tzbnOsnbe8TXEG0AASNaKZddnpHKw7fET8E++Pg==",
139+
"path": "microsoft.extensions.logging/9.0.0",
140+
"hashPath": "microsoft.extensions.logging.9.0.0.nupkg.sha512"
141+
},
142+
"Microsoft.Extensions.Logging.Abstractions/9.0.0": {
143+
"type": "package",
144+
"serviceable": true,
145+
"sha512": "sha512-g0UfujELzlLbHoVG8kPKVBaW470Ewi+jnptGS9KUi6jcb+k2StujtK3m26DFSGGwQ/+bVgZfsWqNzlP6YOejvw==",
146+
"path": "microsoft.extensions.logging.abstractions/9.0.0",
147+
"hashPath": "microsoft.extensions.logging.abstractions.9.0.0.nupkg.sha512"
148+
},
149+
"Microsoft.Extensions.Options/9.0.0": {
150+
"type": "package",
151+
"serviceable": true,
152+
"sha512": "sha512-y2146b3jrPI3Q0lokKXdKLpmXqakYbDIPDV6r3M8SqvSf45WwOTzkyfDpxnZXJsJQEpAsAqjUq5Pu8RCJMjubg==",
153+
"path": "microsoft.extensions.options/9.0.0",
154+
"hashPath": "microsoft.extensions.options.9.0.0.nupkg.sha512"
155+
},
156+
"Microsoft.Extensions.Primitives/9.0.0": {
157+
"type": "package",
158+
"serviceable": true,
159+
"sha512": "sha512-N3qEBzmLMYiASUlKxxFIISP4AiwuPTHF5uCh+2CWSwwzAJiIYx0kBJsS30cp1nvhSySFAVi30jecD307jV+8Kg==",
160+
"path": "microsoft.extensions.primitives/9.0.0",
161+
"hashPath": "microsoft.extensions.primitives.9.0.0.nupkg.sha512"
162+
},
163+
"Obsidian.API/1.0.0-nightly-46": {
164+
"type": "package",
165+
"serviceable": true,
166+
"sha512": "sha512-qa1kTNMuzIQwNenxR09akwIb81Rc94iz1IrpJxgwTUfR8PUysL6X5FIUWVPcb1dv3Ta/lLvJpYnSL6Pz4dVVQg==",
167+
"path": "obsidian.api/1.0.0-nightly-46",
168+
"hashPath": "obsidian.api.1.0.0-nightly-46.nupkg.sha512"
169+
},
170+
"SharpNoise/0.12.1.1": {
171+
"type": "package",
172+
"serviceable": true,
173+
"sha512": "sha512-YU87vP4pCJpEtu+yigyZFEzZPy02rf49v3YfrTN/f9YTfk1SZFfOTUKYhPcP4r1+4MpNNOBbu7UNlTvcwpx5Ww==",
174+
"path": "sharpnoise/0.12.1.1",
175+
"hashPath": "sharpnoise.0.12.1.1.nupkg.sha512"
176+
},
177+
"System.Collections.Immutable/8.0.0": {
178+
"type": "package",
179+
"serviceable": true,
180+
"sha512": "sha512-AurL6Y5BA1WotzlEvVaIDpqzpIPvYnnldxru8oXJU2yFxFUy3+pNXjXd1ymO+RA0rq0+590Q8gaz2l3Sr7fmqg==",
181+
"path": "system.collections.immutable/8.0.0",
182+
"hashPath": "system.collections.immutable.8.0.0.nupkg.sha512"
183+
},
184+
"System.Reflection.Metadata/8.0.0": {
185+
"type": "package",
186+
"serviceable": true,
187+
"sha512": "sha512-ptvgrFh7PvWI8bcVqG5rsA/weWM09EnthFHR5SCnS6IN+P4mj6rE1lBDC4U8HL9/57htKAqy4KQ3bBj84cfYyQ==",
188+
"path": "system.reflection.metadata/8.0.0",
189+
"hashPath": "system.reflection.metadata.8.0.0.nupkg.sha512"
190+
}
191+
}
192+
}
11.5 KB
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"runtimeOptions": {
3+
"tfm": "net9.0",
4+
"rollForward": "LatestMinor",
5+
"framework": {
6+
"name": "Microsoft.NETCore.App",
7+
"version": "9.0.0"
8+
},
9+
"configProperties": {
10+
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)