<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Assembly and Namespace Configuration -->
<AssemblyName>Sbroenne.ExcelMcp.McpServer</AssemblyName>
<RootNamespace>Sbroenne.ExcelMcp.McpServer</RootNamespace>
<!-- MCP Server doesn't need XML documentation warnings - API docs are in MCP schema -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
<!-- Allow test project to access internal members (e.g., SetTelemetryClient) -->
<InternalsVisibleTo>Sbroenne.ExcelMcp.McpServer.Tests</InternalsVisibleTo>
<!-- Version Information -->
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<!-- NuGet MCP Server Configuration -->
<PackageId>Sbroenne.ExcelMcp.McpServer</PackageId>
<!-- Note: McpServer type is added via _AddMcpServerPackageType target below
because .NET 8 SDK unconditionally sets PackageType=DotnetTool when PackAsTool=true -->
<Title>MCP Server for Excel</Title>
<Description>Excel automation for AI assistants - manage Sheets, Power Query, DAX, VBA, Tables, Ranges, Formatting, Validation and more. Requires Excel to be installed. Only runs on Windows.</Description>
<PackageTags>mcp;model-context-protocol;excel;microsoft;office;spreadsheet;automation;power-query;m-language;dax;data-model;power-pivot;vba;macro;table;copilot;ai;github-copilot;data-analysis</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>See https://github.com/sbroenne/mcp-server-excel/releases for release notes</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<!-- .NET Tool Configuration -->
<PackAsTool>true</PackAsTool>
<ToolCommandName>mcp-excel</ToolCommandName>
<!-- Multi-Architecture Support for Windows x64 and ARM64 -->
<PublishSelfContained>false</PublishSelfContained>
<PublishTrimmed>false</PublishTrimmed>
<!-- RuntimeIdentifier removed for portable deployment -->
<!-- Package Validation -->
<EnablePackageValidation>true</EnablePackageValidation>
<!-- Application Insights Connection String - embedded at build time from environment variable -->
<!-- CI/CD sets APPINSIGHTS_CONNECTION_STRING before build; local dev builds get empty string (telemetry disabled) -->
<AppInsightsConnectionString Condition="'$(AppInsightsConnectionString)' == ''">$(APPINSIGHTS_CONNECTION_STRING)</AppInsightsConnectionString>
</PropertyGroup>
<!-- Workaround for .NET 8 SDK unconditionally setting PackageType=DotnetTool when PackAsTool=true.
This target runs before Pack and appends McpServer to the package type.
In .NET 10+, just setting <PackageType>McpServer</PackageType> would work. -->
<Target Name="_AddMcpServerPackageType" BeforeTargets="GenerateNuspec;Pack">
<PropertyGroup>
<PackageType>$(PackageType);McpServer</PackageType>
</PropertyGroup>
</Target>
<!-- Generate TelemetryConfig.g.cs with the connection string at build time -->
<!-- Note: Uses inline task because WriteLinesToFile treats semicolons as line separators -->
<UsingTask TaskName="WriteTextFile" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<FilePath ParameterType="System.String" Required="true" />
<Content ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
System.IO.File.WriteAllText(FilePath, Content);
</Code>
</Task>
</UsingTask>
<Target Name="GenerateTelemetryConfig" BeforeTargets="BeforeCompile;CoreCompile">
<PropertyGroup>
<TelemetryConfigFile>$(IntermediateOutputPath)TelemetryConfig.g.cs</TelemetryConfigFile>
<TelemetryConfigContent>// Auto-generated at build time - do not edit
namespace Sbroenne.ExcelMcp.McpServer.Telemetry%3B
internal static class TelemetryConfig
{
public const string ConnectionString = "$(AppInsightsConnectionString)"%3B
}
</TelemetryConfigContent>
</PropertyGroup>
<WriteTextFile FilePath="$(TelemetryConfigFile)" Content="$(TelemetryConfigContent)" />
<ItemGroup>
<Compile Include="$(TelemetryConfigFile)" />
</ItemGroup>
</Target>
<!-- Release Build Optimizations -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<!-- Disable debug symbols in Release builds -->
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<!-- Generate XML docs for analyzers but exclude from publish -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- Additional optimization flags -->
<Optimize>true</Optimize>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
</PropertyGroup>
<!-- Exclude XML and PDB files from publish output -->
<Target Name="RemoveXmlAndPdbFromPublish" AfterTargets="Publish" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<XmlFilesToDelete Include="$(PublishDir)**\*.xml" />
<PdbFilesToDelete Include="$(PublishDir)**\*.pdb" />
</ItemGroup>
<Delete Files="@(XmlFilesToDelete)" />
<Delete Files="@(PdbFilesToDelete)" />
<Message Text="Removed XML documentation and PDB files from publish output" Importance="high" />
</Target>
<ItemGroup>
<ProjectReference Include="..\ExcelMcp.Core\ExcelMcp.Core.csproj">
<!-- Don't copy XML docs from referenced projects in Release builds -->
<Private>true</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ModelContextProtocol" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<!-- Application Insights Worker Service SDK for telemetry (Users, Sessions, Funnels, User Flows) -->
<!-- Worker Service SDK provides proper DI integration, auto-collection modules, and host lifetime awareness -->
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<!-- Include MCP Server Configuration -->
<Content Include=".mcp/server.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>.mcp/server.json</PackagePath>
</Content>
<!-- Include README and LICENSE in package -->
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<!-- Embed Prompt Markdown Files -->
<EmbeddedResource Include="Prompts\Content\*.md" />
<EmbeddedResource Include="Prompts\Content\Completions\*.md" />
<EmbeddedResource Include="Prompts\Content\Elicitations\*.md" />
</ItemGroup>
</Project>