This shell script configures a NuGet package source, restores packages in a.NET project, and builds the project using MSBuild. The script creates a configuration file, sets up symbolic links, updates the NuGet package source, and builds a specific project.
echo
'<configuration> \
<packageRestore> \
<add key="enabled" value="True" /> \
<add key="automatic" value="True" /> \
</packageRestore> \
<packageSources> \
<add key="nuget.org" value="https://www.nuget.org/api/v2/" /> \
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> \
<add key="teamCity" value="http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc" /> \
</packageSources> \
</configuration>' > / act.subscription.management /
.
nuget / NuGet.Config
ln - s
subscription.myact / Subscription.MyAct
ln - s
subscription.core / Subscription.Core
ln - s
subscription.entitlement / Subscription.Entitlement
ln - s
subscription.integrations / Subscription.Integrations
ln - s
subscription.identitymanagement / Subscription.IdentityManagement
nuget
sources
update - Name
teamCity - source
http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc -User {username} -pass {password} -configFile .nuget/NuGet.Config -StorePasswordInClearText
nuget
update / act.subscription.management / act.subscription.management.sln
msbuild
Subscription.IdentityManagement.csproj
// Configuration Object
class Config {
constructor() {
this.packageRestore = {
enabled: true,
automatic: true,
};
this.packageSources = [
{
key: 'nuget.org',
value: 'https://www.nuget.org/api/v2/',
},
{
key: 'nuget.org',
value: 'https://api.nuget.org/v3/index.json',
protocolVersion: 3,
},
{
key: 'teamCity',
value: 'http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc',
},
];
}
}
// Create Config Object
const config = new Config();
// Generate Config XML
function generateConfigXml(config) {
return `
<configuration>
<packageRestore>
<add key="enabled" value="${config.packageRestore.enabled}" />
<add key="automatic" value="${config.packageRestore.automatic}" />
</packageRestore>
<packageSources>
${config.packageSources.map((source) => `
<add key="${source.key}" value="${source.value}" />
`).join('')}
</packageSources>
</configuration>
`;
}
// Generate Config XML
const configXml = generateConfigXml(config);
// Output Config XML
console.log(configXml);
// Create Symlinks
function createSymlink(src, dst) {
console.log(`Creating symlink: ${src} -> ${dst}`);
}
// Create Symlinks
const symlinks = [
['subscription.myact', 'Subscription.MyAct'],
['subscription.core', 'Subscription.Core'],
['subscription.entitlement', 'Subscription.Entitlement'],
['subscription.integrations', 'Subscription.Integrations'],
['subscription.identitymanagement', 'Subscription.IdentityManagement'],
];
symlinks.forEach(([src, dst]) => createSymlink(src, dst));
// Update NuGet Sources
function updateNugetSources(configFile, source, username, password, url) {
return `
nuget sources update -Name teamCity -source ${url} -User ${username} -pass ${password} -configFile ${configFile}
`;
}
// Update NuGet Sources
const nugetSourcesUpdate = updateNugetSources('.nuget/NuGet.Config', 'http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc', '{username}', '{password}', 'http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc');
// Output NuGet Sources Update
console.log(nugetSourcesUpdate);
// Update Solution
function updateSolution(solutionFile) {
return `
nuget update ${solutionFile}
`;
}
// Update Solution
const solutionUpdate = updateSolution('act.subscription.management.sln');
// Output Solution Update
console.log(solutionUpdate);
// Build Project
function buildProject(projectFile) {
return `
msbuild ${projectFile}
`;
}
// Build Project
const projectBuild = buildProject('Subscription.IdentityManagement.csproj');
// Output Project Build
console.log(projectBuild);
Code Breakdown
This is a shell script that appears to be configuring a NuGet package source and restoring packages in a.NET project.
The script creates a configuration file NuGet.Config
with the following content:
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="teamCity" value="http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc" />
</packageSources>
</configuration>
The script creates symbolic links to various directories:
ln -s subscription.myact /Subscription.MyAct
ln -s subscription.core /Subscription.Core
ln -s subscription.entitlement /Subscription.Entitlement
ln -s subscription.integrations /Subscription.Integrations
ln -s subscription.identitymanagement /Subscription.IdentityManagement
The script updates the NuGet package source and restores packages in the act.subscription.management
project:
nuget sources update -Name teamCity -source http://teamcity.actops.com/httpAuth/app/nuget/v1/FeedService.svc -User {username} -pass {password} -configFile.nuget/NuGet.Config -StorePasswordInClearText
nuget update /act.subscription.management /act.subscription.management.sln
The script builds the Subscription.IdentityManagement.csproj
project using MSBuild:
msbuild Subscription.IdentityManagement.csproj
Note that the script assumes the presence of certain files and directories, such as subscription.myact
, subscription.core
, etc. It also requires a NuGet.Config
file in the current working directory.